• 2008年04月20日

    留言板 - [程序人生]

    技术关键字

    编程语言:C/C++,Java,C#,VB

    脚本语言:JavaScript,Actionscript,VBScript

    Web开发:ASP,PHP,JSP,Flex,XML,HTML

    数据库:SQL,Oracle,SQL Server,MySQL,

     框架:Struts,Spring,Hibernate,JSF,WebWork,iBatis,Dojo,GWT,DWR

    GIS:Skyline TerraBuilder,TerraExporer,ArcGIS,ArcInfo,ArcGlobe

    软件:Eclipse,Netbeans,Visual Studio,Dreamweaver,Flash,Photoshop,Illustrator,Firework,Painter,Maya,After Efects,CorelDRAW,3DS MAX,Premiere,PowerDesigner,Rational Rose,Flex Builder,Skyline

    其他:JDBC,Swing,JUnit,Log4j,Ajax,IOC,AOP,EJB,DOM,RIA

  • 首先强调一下,svn的安装路径中不要带空格,比如D:\Program Files\svn这样的路径,Program和Files之间的空格会引起apache的配置错误(稍后说明)。D:\svn这样就没事了

    新建一个文件夹,用于存放提交后的文件,比如D:\svnroot

    apache的配置:打开httpd.conf文件(在apache安装目录下的conf文件夹里),在最后一行中加入

    LoadModule dav_module modules/mod_dav.so

    LoadModule dav_svn_module D:/svn/bin/mod_dav_svn.so

    LoadModule authz_svn_module D:/svn/bin/mod_authz_svn.so
    <Location /svn>
      DAV svn
      SVNParentPath D:/svnroot
    </Location>

    可以看到apache的配置格式是,各个元素之间加空格,这也说明了svn安装目录最好不要有空格,要不然Program Files虽然只是一个文件夹的名称,但被当成两个元素了。

  • 下载svn和apache,下载地址

    apache:http://httpd.apache.org/

    svn:http://sourceforge.net/projects/win32svn/

    svn有好几个版本,各个版本的都有各自的网站。最初的官网是http://subversion.tigris.org/,现在已经转移到 http://subversion.apache.org/,而apache网站上只提供svn的更新信息,本身不存在svn软件的下载,不过有提供所有版本的下载链接网站列表http://subversion.apache.org/packages.html。

    在上面下载列表中,windows共有5个下载版本,分别是

    CollabNet,SlikSVN,VisualSVN Server,WANdisco,Win32Svn

    其中CollabNet是功能最强大的,因为svn的创始者就是CollabNet,不过这个版本因为功能最多,所以整个软件包也是最臃肿的,安装包就有100多M,而且因为是运行在java平台上的,要占用很大的内存资源。

    SlikSVN和Win32Svn这两个基本是一样的,都只有svn的内核,没有界面,也就是使用的时候只能用命令行操作。这两者稍微有些区别,比如Win32Svn提供了和apache的库文件,而SlikSVN没有。

    VisualSVN Server是最傻瓜化的svn,安装和配置都是有图形界面,操作起来很方便。

    WANdisco还没用过,暂时不清楚。

    最原始的svn(SlikSVN和Win32Svn就是),不存在客户端和服务端之分,本身svn既是服务端又是客户端。相当于在本地计算机上进行版本控制。CollabNet和VisualSVN Server已经提供远程https协议访问和提交更新的功能。对于原始的svn,可以通过和apache结合,来实现这个功能。

    这里特别指出的是Win32Svn,这个相当于以前在官网上http://subversion.tigris.org/下载到的svn(现在 http://subversion.tigris.org/已经不提供svn的下载,具体原因未知),因为是svn的核心部分,所以安装文件比较小,只有6.7M,里面已经包含了操作手册。接下去要介绍的svn和apache的配置就是按照操作手册上的说明配置。

  • 在Linux系统下,默认就是使用make来生成项目,而在windows下,则是使用默认的CDT Internal Builder这时只要把它改成Gnu make Builder就行了。

    在新创建项目时,点击Advanced setting

    左边选择C/C++ Build,会发现,Builder type这项是不可选的

    在Tool Chain Editor中,把current builder改成Gnu make Builder

    再切换过来,可看到,builder type这项可选

    创建完项目后,编译,eclipse自动生成了3个makefile文件

  • 2010年07月14日

    PHP和Apache配置 - [编程开发]

    其实主要是在Apache中配置PHP,而PHP的配置会因使用的模块所决定。

    配置的文件对象分别是Apache中conf目录下的httpd.conf文件和PHP目录下的php.ini文件

    配置内容,在httpd.conf中

    AddType application/x-httpd-PHP .php
    PHPIniDir "D:/PHP/"
    LoadModule php5_module "D:/PHP/php5apache2_2.dll"

    其中D:/PHP/是PHP安装(或解压)后的目录

    在Apache配置好PHP后,就基本可以运行PHP程序了,而在php.ini中一般不需要修改。除非需要扩展某些功能,比如mysql数据库的连接读写操作就需要修改php.ini文件

    绝大部分PHP程序都要访问数据库,MySQL是PHP最常用的数据库,这时候就要对PHP中MySQL模块功能进行扩展。在php.ini中找到extension_dir这个属性把它设为extension_dir = "D:/PHP/ext/",ext是PHP目录下的一个子目录,所有扩展扩展都放在里面,再找到;extension=php_mysql.dll,把前面的分号去掉。如果要扩展其他模块,同样道理把前面的分号去掉。

    此时还是不能连接数据库,还需把PHP目录下的php5ts.dll和libmysql.dll这两个文件加入环境变量,操作方式有两种,一种是直接把这两个文件复制到C:/windows/system32下面,还有另外一种方式是把PHP目录添加到环境变量path中。

     

  • 2009年11月13日

    eclipse创建WebServices - [编程开发]

    新建一个Dynamic Web Project

    创建一个普通Java类

    接下去按Finish就创建好了

  • 2009年11月13日

    360杀毒 - [互联网络]

    免费的杀毒软件,支持一下

  • 首先BlazeDS包含了两部分的内容,一个是客户端Flex,另一个是远程服务端Java。为了能同时编写Flex代码和Java代码。Flex Builder一般以插件形式安装,也就是要在Eclipse中装一个插件版的Flex Builder。而blazeds下载下来默认是blazeds.war的文件,至于为什么是war格式的,以下过程中会用到。

    创建一个Flex Project,在Application server type中选择J2EE,其他都默认,next

    在下来的这个界面中,关键点是Flex WAR file,选择的是下载好的blazeds.war文件,Target runtime可以是任意的容器,一般开发都选用Apache Tomcat(这个一开始就要配置好)。另外Output folder默认是bin-debug,可以改成WebContent/FlexView,符合一般的开发习惯

    接下去的过程都是默认

    最后是创建完毕的工程目录结构

  • 在FlexViewer中,每一个Widget都是一个独立的组件,它们都继承于BaseWidget。现在某一个Widget要访问令外一个widget的属性,就要通过它们所在的共同父类,建立查找关系。

    每一个Widget都是放在名称叫WidgetBox的VBox里,可以通过this.parent来获得这个容器对象。然后再调用这个容器对象的getChildAt方法来获得它的子对象,也就是每一个Widget,但是获得的子对象是DisplayObject类型的,则需要进行强制转换。问题就出在这里了,虽然通过getChildAt获得的子对象,都能够访问它继承于DisplayObject的属性和方法。但就是无法进行转换成BaseWidget类,什么原因,现在还不明白。

    现在有另外一种变通方式,就是用单例模式建立一个中间类,然后两个Widget每次通过这个中间类来通信


  • 2009年07月25日

    Java的Socket编程 - [编程开发]

    server端

    // Fig. 18.4: Server.java
    // Set up a Server that will receive a connection from a client, send
    // a string to the client, and close the connection.
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    public class Server extends JFrame {
     /**
      *
      */
     private static final long serialVersionUID = 1L;
     private JTextField enterField;
     private JTextArea displayArea;
     private ObjectOutputStream output;
     private ObjectInputStream input;
     private ServerSocket server;
     private Socket connection;
     private int counter = 1;

     // set up GUI
     public Server() {
      super("Server");

      Container container = getContentPane();

      // create enterField and register listener
      enterField = new JTextField();
      enterField.setEditable(false);
      enterField.addActionListener(new ActionListener() {

       // send message to client
       //当按下回车键时触发事件
       public void actionPerformed(ActionEvent event) {
        sendData(event.getActionCommand());
        enterField.setText("");
       }
      });

      container.add(enterField, BorderLayout.NORTH);

      // create displayArea
      displayArea = new JTextArea();
      container.add(new JScrollPane(displayArea), BorderLayout.CENTER);

      setSize(300, 150);
      setVisible(true);

     } // end Server constructor

     // set up and run server
     public void runServer() {
      // set up server to receive connections; process connections
      try {

       // Step 1: Create a ServerSocket.
       server = new ServerSocket(12345, 100);

       while (true) {

        try {
         waitForConnection(); // Step 2: Wait for a connection.
         getStreams(); // Step 3: Get input & output streams.
         processConnection(); // Step 4: Process connection.
        }

        // process EOFException when client closes connection
        catch (EOFException eofException) {
         System.err.println("Server terminated connection");
        }

        finally {
         closeConnection(); // Step 5: Close connection.
         ++counter;
        }

       } // end while

      } // end try

      // process problems with I/O
      catch (IOException ioException) {
       ioException.printStackTrace();
      }

     } // end method runServer

     // wait for connection to arrive, then display connection info
     private void waitForConnection() throws IOException {
      displayMessage("Waiting for connection\n");
      connection = server.accept(); // allow server to accept connection
      displayMessage("Connection " + counter + " received from: "
        + connection.getInetAddress().getHostName());
     }

     // get streams to send and receive data
     private void getStreams() throws IOException {
      // set up output stream for objects
      output = new ObjectOutputStream(connection.getOutputStream());
      output.flush(); // flush output buffer to send header information

      // set up input stream for objects
      input = new ObjectInputStream(connection.getInputStream());

      displayMessage("\nGot I/O streams\n");
     }

     // process connection with client
     private void processConnection() throws IOException {
      // send connection successful message to client
      String message = "Connection successful";
      sendData(message);

      // enable enterField so server user can send messages
      setTextFieldEditable(true);

      do { // process messages sent from client

       // read message and display it
       try {
        message = (String) input.readObject();
        displayMessage("\n" + message);
       }
       // catch problems reading from client
       catch (ClassNotFoundException classNotFoundException) {
        displayMessage("\nUnknown object type received");
       }

      } while (!message.equals("CLIENT>>> TERMINATE"));

     } // end method processConnection

     // close streams and socket
     private void closeConnection() {
      displayMessage("\nTerminating connection\n");
      setTextFieldEditable(false); // disable enterField

      try {
       output.close();
       input.close();
       connection.close();
      } catch (IOException ioException) {
       ioException.printStackTrace();
      }
     }

     // send message to client
     private void sendData(String message) {
      // send object to client
      try {
       output.writeObject("SERVER>>> " + message);
       output.flush();
       displayMessage("\nSERVER>>> " + message);
      }

      // process problems sending object
      catch (IOException ioException) {
       displayArea.append("\nError writing object");
      }
     }

     // utility method called from other threads to manipulate
     // displayArea in the event-dispatch thread
     private void displayMessage(final String messageToDisplay) {
      // display message from event-dispatch thread of execution
      SwingUtilities.invokeLater(new Runnable() { // inner class to ensure GUI
                 // updates properly

         public void run() // updates displayArea
         {
          displayArea.append(messageToDisplay);
          displayArea.setCaretPosition(displayArea.getText()
            .length());
         }

        } // end inner class

        ); // end call to SwingUtilities.invokeLater
     }

     Client端

    // Fig. 18.5: Client.java
    // Client that reads and displays information sent from a Server.
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    public class Client extends JFrame {
     /**
      *
      */
     private static final long serialVersionUID = 1L;
     private JTextField enterField;
     private JTextArea displayArea;
     private ObjectOutputStream output;
     private ObjectInputStream input;
     private String message = "";
     private String chatServer;
     private Socket client;

     // initialize chatServer and set up GUI
     public Client(String host) {
      super("Client");

      chatServer = host; // set server to which this client connects

      Container container = getContentPane();

      // create enterField and register listener
      enterField = new JTextField();
      enterField.setEditable(false);
      enterField.addActionListener(new ActionListener() {

       // send message to server
       public void actionPerformed(ActionEvent event) {
        sendData(event.getActionCommand());
        enterField.setText("");
       }
      });

      container.add(enterField, BorderLayout.NORTH);

      // create displayArea
      displayArea = new JTextArea();
      container.add(new JScrollPane(displayArea), BorderLayout.CENTER);

      setSize(300, 150);
      setVisible(true);

     } // end Client constructor

     // connect to server and process messages from server
     private void runClient() {
      // connect to server, get streams, process connection
      try {
       connectToServer(); // Step 1: Create a Socket to make connection
       getStreams(); // Step 2: Get the input and output streams
       processConnection(); // Step 3: Process connection
      }

      // server closed connection
      catch (EOFException eofException) {
       System.err.println("Client terminated connection");
      }

      // process problems communicating with server
      catch (IOException ioException) {
       ioException.printStackTrace();
      }

      finally {
       closeConnection(); // Step 4: Close connection
      }

     } // end method runClient

     // connect to server
     private void connectToServer() throws IOException {
      displayMessage("Attempting connection\n");

      // create Socket to make connection to server
      client = new Socket(InetAddress.getByName(chatServer), 12345);

      // display connection information
      displayMessage("Connected to: " + client.getInetAddress().getHostName());
     }

     // get streams to send and receive data
     private void getStreams() throws IOException {
      // set up output stream for objects
      output = new ObjectOutputStream(client.getOutputStream());
      output.flush(); // flush output buffer to send header information

      // set up input stream for objects
      input = new ObjectInputStream(client.getInputStream());

      displayMessage("\nGot I/O streams\n");
     }

     // process connection with server
     private void processConnection() throws IOException {
      // enable enterField so client user can send messages
      setTextFieldEditable(true);

      do { // process messages sent from server

       // read message and display it
       try {
        message = (String) input.readObject();
        displayMessage("\n" + message);
       }

       // catch problems reading from server
       catch (ClassNotFoundException classNotFoundException) {
        displayMessage("\nUnknown object type received");
       }

      } while (!message.equals("SERVER>>> TERMINATE"));

     } // end method processConnection

     // close streams and socket
     private void closeConnection() {
      displayMessage("\nClosing connection");
      setTextFieldEditable(false); // disable enterField

      try {
       output.close();
       input.close();
       client.close();
      } catch (IOException ioException) {
       ioException.printStackTrace();
      }
     }

     // send message to server
     private void sendData(String message) {
      // send object to server
      try {
       output.writeObject("CLIENT>>> " + message);
       output.flush();
       displayMessage("\nCLIENT>>> " + message);
      }

      // process problems sending object
      catch (IOException ioException) {
       displayArea.append("\nError writing object");
      }
     }

     // utility method called from other threads to manipulate
     // displayArea in the event-dispatch thread
     private void displayMessage(final String messageToDisplay) {
      // display message from GUI thread of execution
      SwingUtilities.invokeLater(new Runnable() { // inner class to ensure GUI
                 // updates properly

         public void run() // updates displayArea
         {
          displayArea.append(messageToDisplay);
          displayArea.setCaretPosition(displayArea.getText()
            .length());
         }

        } // end inner class

        ); // end call to SwingUtilities.invokeLater
     }

     // utility method called from other threads to manipulate
     // enterField in the event-dispatch thread
     private void setTextFieldEditable(final boolean editable) {
      // display message from GUI thread of execution
      SwingUtilities.invokeLater(new Runnable() { // inner class to ensure GUI
                 // updates properly

         public void run() // sets enterField's editability
         {
          enterField.setEditable(editable);
         }

        } // end inner class

        ); // end call to SwingUtilities.invokeLater
     }

     public static void main(String args[]) {
      Client application;

      if (args.length == 0)
       application = new Client("127.0.0.1");
      else
       application = new Client(args[0]);

      application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      application.runClient();
     }

    } // end class Client

  • mxml中的actionscript代码:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
     <mx:Script >
      import mx.controls.Alert;
      import flash.external.ExternalInterface;
      public function init():void {
       ExternalInterface.addCallback("hello", say);
      }
      public function say():void {
       Alert.show("hello");
      }
     </mx:Script>
    </mx:Application>

    Javascript代码:

    script type="text/javascript">
      function thisMovie(movieName) {
              if (navigator.appName.indexOf("Microsoft") != -1) {
                  return window[movieName];
              } else {
                  return document[movieName];
              }
          }

      function btclick() {
       thisMovie("Flex").hello();
      }
     </script>