1. 获取java程序的系统参数

    执行java程序时传入的系统参数可以通过以下方式在程序中获取: java  -D参数1=值1  java程序名     Properties props = new Properties(System.getProperties());     String outputMode = props.getProperty("参数1");

    2017/02/12 iteye

  2. 日志系统

    异步log to file 1. 启动一个多线程,维护一个List列表。List中存放的是需要log的字符串。早期用Vector来考虑同步的问题,甚至可以包装Vector。加入wait/notify机制。 2. 主程序启动时打开文件,主程序结束时关闭文件。其他还有异常,rotate file时也需要关闭文件。   // Open the file output stream             logOutputStream = new FileOutputStream(this.fileName);          &nbs

    2017/02/12 iteye

  3. LDAP command

    #install ldap 1. install BerkeleyDB.4.6 2. add /usr/local/BerkeleyDB.4.6/lib to /etc/ld.so.conf, then execute ldconfig 3. env CPPFLAGS="-I/usr/local/BerkeleyDB.4.6/include" LDFLAGS="-L/usr/local/BerkeleyDB.4.6/lib"  ./configure --prefix /usr/local/openldap 4. make depend 5. make 6. make install 7. go to /usr/local/openldap/libexec execute ./slapd 8. ps -aux | grep slapd verify LDAP server is up #install ldap browser #for error:Can't connect to X11 windo

    2017/02/12 iteye

  4. RMI Implementation

    RMI provides the solution of communication between Java processes. For building a RMI Server/Client Application, below steps are considered: 1. define the Remote interfaces extends from java.rmi.Remote    these interfaces will also be provided to client.    note: all remote interfaces throw java.rmi.RemoteException 2. implement the remote interfaces, the implementation classes also extend java.rmi.server.UnicastRemoteObject to export the remote objects. 3. use java

    2017/02/12 iteye

  5. database batching insert

    In DB2, e.g if you issue below sql statement 100 times, insert into TableA (id , fields) values (1, 'val1'); insert into TableA (id , fields) values (2, 'val2'); insert into TableA (id , fields) values (3, 'val3'); ......................... insert into TableA (id , fields) values (100, 'val100'); if you set jdbc batch_size to 50, it could be only issue two sql to db instead as below: insert into TableA (id , fields) values (1, 'val1') , (2, 'val2') ,(3, 'val3') ,(4, 'val4') ,......,(50, 'val50') insert into TableA (id , fields) values (51, 'val51') , (52, 'val52') ,(53, 'val53') ,(54, 'val54'),...... ,(100, 'val100')

    2017/02/12 iteye

  6. Message Broker

    Message Broker based on RMI

    2017/02/12 iteye

  7. 多线程等待机制

    现有一个遗留系统中,用到了很多多线程。其中等待机制是这么做的: 1. 主线程在需要等待的时候,先开启一个等待线程。初始化时预定一个时间。等待线程启动后立刻 wait()/wait(nTime). 2. 主线程 join 等待线程 3. 外部事件到达时,interrupt 等待线程。E.g. in a listener or update method 4. 主线程继续执行下去 这种方式利用了InterruptedException控制业务逻辑,除了这个缺点外不知还有没有别的弊端?

    2017/02/12 iteye

  8. Hibernate笔记

    inverse=true | false   2. cascade   3. lazy-loading   4. session-per-request & open session filter   5. transaction demarcation

    2017/02/12 iteye