This blog records some ideas, notes, and information of my works and studies in information technology.

Sunday, June 28, 2009

Load Properties in Java

http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html?page=2
Complete introduction
A simple example~

[Important!]
將設定檔放在Jar包外部執行!
final InputStream inStream = ClassLoader.getSystemResourceAsStream("EJBProp.properties");
取得的方式較簡單
重點在MANIFEST.MF中 設定Class-Path: ./
表示需從 class loader所在的位置搜尋檔案~!!

Eclipse plug-in: Fat Jar

http://www.javaworld.com.tw/jute/post/view?bid=20&id=111801&sty=1&tpg=1&age=0
Experience sharing in JavaWorld.TW

Official Site of Fat-Jar

It really works!!

Thursday, June 25, 2009

SCJD Exam with J2SE 5.0--Chapter 7

  • Socket Server P. 216
     。xxxSocketServer extends Thread:
    1. new DvdSocketServer(dbLocation, port).start();
    2. ServerSocket aServerSocket = new ServerSocket(port);
    3. while (true) {
    Socket aSocket = aServerSocket.accept();
    DbSocketRequest request = new DbSocketRequest(dbLocation, aSocket);
    request.start();
    }
    。xxxSocketRequest implements Runnable:
    1. handle the input and output stream
    2. call executeRequest();
  • Application Protocol 1. Need a "Command" object to perform a protocol

Wednesday, June 24, 2009

JBossWS 2.0.GA - JAX-WS User Guide

http://www.jboss.org/jbossws/docs/jaxws_userguide-2.0/index.html#d0e126
Dynamic Web

EJB

My methods:
  1. It's easy to generate WSDL by writing SessionBean anotated with @WebService. You can find out the URL of the wsdl in the information of the console messages.
    http://localhost:8080/TSMEar-TSMEJB/AdminSDKeyChangeSessionBean?wsdl
  2. Use Eclipse to generate an JBossws client:
    a. New a dynamic web project.
    b. New a Web Service Client associated with the former web project
    --> try to generate specific client stubs!!!
    c. Copy the stubs to your own client project...
    It's better to include JBossws 3.1.2.GA library because it's lighter than JBoss server runtime!!
Another option for Web Services: Axis
It seems better to write client codes!

Java Certification

http://www.sun.com/training/certification/java/index.xml

The whole map...
SCEA is the highest level of java language~!!
SCJD is also a harder challenge~!!

I have gotten SCJP & SCWCD
Now I'm preparing SCBCD~!

A comparison of JAX-RPC & JAX-WS

http://www.ibm.com/developerworks/webservices/library/ws-tip-jaxwsrpc.html

Enterprise JavaBeans, 3.0 -- Chapter 19

EJB 3.0 supports
  • Java API for XML-based Web Services (JAX-WS) 2.0
  • Java API for XML-based RPC (JAX-RPC) 1.1
  • SOAP with Attachments API for Java (SAAJ)
  • Java API for XML Registries (JAXR)
    --access web services registries, UDDI

Tuesday, June 23, 2009

Enterprise JavaBeans, 3.0 -- Chapter 18

  • Http Tunneling
  • SOAP 1.1
  • WSDL 1.1

Saturday, June 20, 2009

J2ME Polish !!

http://www.j2mepolish.org/cms/topsection/home.html

J2ME Polish is a suite of tools and technologies aimed at mobile developers and companies within the mobile space.

Main features of J2ME Polish include:

  • Lush: A UI toolkit that is highly flexible and that can be designed outside of the application's source code.
  • Janus: A toolset for porting mobile application to different handsets and different technology platforms.
  • Touch: Technology for accessing server side content and communicating with remote parties.
  • Trunk: A persistence solution that allows you to load and save complex data with a single line of code.
  • Marjory: Our community maintained device database.

Set up SSL in JBoss

http://polinwei.blogspot.com/2009/02/jboss-jboss-ssl-https.html

Some steps are required!

Friday, June 19, 2009

Enterprise JavaBeans, 3.0 -- Chapter 12

Thursday, June 18, 2009

CVS Converter...

http://sourceforge.net/projects/javacsv/
http://www.csvreader.com/java_csv_samples.php
This is the package I use now.

Apache seems developing a bigger project of CSV...
But the project hasn't been updated since 17 May, 2008.
Is there any hope for this project?

Tuesday, June 16, 2009

How to transfer JSON to JQuery client in Struts 1.x

Other programmer's idea
http://www.junlu.com/msg/322793.html

JSON ORG

JSON-lib

  1. Download JSON-lib and install it into Web project
  2. There is nothing special required to do to pass the parameter to Actions.
    Just follow JQuery's function:
    $.post("/TSMWeb/cardImportAction.do", {actionType: "initAjax", comAccount: issuerSelectValue}, issuerSelectCallBack, "json");
  3. In Struts 2.x, the only thing you need to do is set up the struts.xml to notify the framework packing the response in JSON format.
  4. In Struts 1.x, you should create a JSONObject to transfer your java object into JSON format and use an "almost empty" JSP to send JSON messages:


    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    ${tsmJSON}

  5. Save your JSON Object with a key name "tsmJSON" by calling request.setAttribute().
  6. That's it! Now you can catch the response in JSON format in your client JSP!

Monday, June 15, 2009

Sunday, June 14, 2009

Tips of JBoss

  1. If your EJB wants to include external libraries, you should pack those libraries with EJB.jar into an Ear file and set up the Class-Path in a MANIFEST.MF file in the META-INF dir of the EJB.jar
    --> Another crude way: set system constant--> JBOSS_CLASSPATH = %HSM's lib path%
    That would set up the classpath of JBoss's class loader(not very good...)

Tips of Eclipse

  1. Windows-->Preferences-->General-->Editors-->Text Editors
    a. Insert spaces for tabs
    b. Show line numbers
  2. Windows-->Preferences-->Java-->Code Style-->Formatter
    a. Set up how to automatically modify the codes.
  3. When you generate a jsp file, remember setting up encoding method in page directive or you can't save what you modify in the file in that encoding. ( Eclipse will generate Encoding Error!)
  4. (Any project) Properties-->Java Compiler-->Building: Output folder can set up what kinds of files you want to copy to the output folder!!

Saturday, June 13, 2009

EJB chapters haven't been read!

high priority: Finished!!
low priority: 6, 7, 8, 20, 21

Now is time to practice the exam...

Friday, June 12, 2009

The introduction of SCBCD

Sun Certified Business Component Developer for the Java Platform, Enterprise Edition 5 (CX-310-091)


EJB 3.0 Overview


  • Identify the uses, benefits, and characteristics of Enterprise JavaBeans technology, for version 3.0 of the EJB specification.
  • Identify the APIs that all EJB 3.0 containers must make available to developers.
  • Identify correct and incorrect statements or examples about EJB programming restrictions.
  • Match the seven EJB roles with the corresponding description of the role's responsibilities.
  • Describe the packaging and deployment requirements for enterprise beans.
  • Describe the purposes and uses of annotations and deployment descriptors, including how the two mechanisms interact, how overriding is handled, and how these mechanisms function at the class, method, and field levels.

Thursday, June 11, 2009

How to save binary data into Database

There are two ways to solve this problem.
  1. Base64: http://en.wikipedia.org/wiki/Base64
    This encoding method can transform binary data into special text format. The encoding method requires some future research!
  2. Hex: Transfer Hex byte into Hex String! The advantage of this encoding method is readable!
    ex: byte[]{00, a0, 30} --> String: "00a030"
Both encoding methods can be found in apache commons codec package!
These are two only ways to transfer binary data into Database.

Wednesday, June 10, 2009

How to set up Log4j parameters in JBoss?

[JBOSS_HOME]\server\default\conf\jboss-log4j.xml
Modify this file!