Total Pageviews

2011/04/07

Utilize Recursive Java Decompiler to Decompile Jar File



2. Unzip jd-gui-0.3.3.windows.zip and execute jd-gui.exe

3. assign jar file which you want to do decompile



4. File --> Save All Sources




6. Install Doxygen

7. Assign project name, source code directory, destination directory. And check "Scan
recursively"


8. Change to "Mode", and do some configuration

9. Change to "Output", and do some configuration

10. Change to "Diagram", and do some configuration

11. Click "Run" tab, and click "Run doxygen"

12. Check result

2011/04/01

Extract Method Refactoring Example

Extract Method is a refactoring operation that provides an easy way to create a new method from a code fragment in an existing member.

Using Extract Method, you can create a new method by extracting a selection of code from inside the code block of an existing member. The new, extracted method contains the selected code, and the selected code in the existing member is replaced with a call to the new method. Turning a fragment of code into its own method lets you quickly and accurately reorganize code for better reuse and readability.

Extract Method has the following benefits:
1. Encourages best coding practices by emphasizing discrete, reusable methods.
2. Encourages self-documenting code through good organization.
3. When descriptive names are used, high-level methods can read more like a series of comments.
4. Encourages the creation of finer-grained methods to simplify overriding.
5. Reduces code duplication.

實例說明
我們在Controller中,會撰寫新增、修改、刪除等method,其中在新增與修改的部份,會將前端form bean的value轉成entity class,然後再呼叫insert or update method,其code snippets如下:

Extract Method Refactoring三部曲
1. 選取要進行refactor的部分

2. 按右鍵-->Refactor-->Extract Method

3. 給予新的method name --> OK


檢查Refactor後的結果

Eclipse將原本set的動作抽離成一個獨立的method


insert與update的method中,原本重複的動作只要用covertBeanToEntity此method取代即可,避免code duplication

2011/03/25

Implementing a simple toString() with Apache Commons

我們在Web開發的時候,JSP頁面參數是透過form bean傳遞,有時候需要印出form bean裡頭的valuedebug,大家可以在form bean中,override toString(),如以下寫法

public String toString() {

return ToStringBuilder.reflectionToString(this);

}

實作如下

public static void main(String[] args) {

// set value to value object

Nigw002PK vo = new Nigw002PK();

vo.setCarryDate("1");

vo.setCarrySeqNo("2");

vo.setCaseStus("3");

vo.setMtgTp("4");

// print value object by toString()

System.out.println(vo.toString());

}

印出結果入下:gov.fdc.nig.domain.Nigw002PK@63396339[mtgTp=4,caseStus=3,taxCd=,carryDate=1,carrySeqNo=2,vioNo=>]

Reference: http://blogs.bytecode.com.au/glen/2007/10/05/implementing-a-simple-tostring---with-apache-commons.html

2011/03/16

WTRN0037W: The transaction service encountered an error on an xa_recover operation


As I start up WAS(WebSphere Application Server) V7, it show error messages as bellows:
[2011/3/16 17:30:48:784 CST] 0000000b XARminst E WTRN0037W: The transaction service encountered an error on an xa_recover operation. The resource was com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@702d702d. The error code was XAER_RMERR. The exception stack trace follows: javax.transaction.xa.XAException
at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java:709)
at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.recover(WSRdbXaResourceImpl.java:1044)
at com.ibm.ws.Transaction.JTA.XARminst.recover(XARminst.java:140)
at com.ibm.ws.Transaction.JTA.XARecoveryData.recover(XARecoveryData.java:571)
at com.ibm.tx.jta.PartnerLogTable.recover(PartnerLogTable.java:389)
at com.ibm.tx.jta.RecoveryManager.resync(RecoveryManager.java:1523)
at com.ibm.ws.tx.jta.RecoveryManager.performResync(RecoveryManager.java:126)
at com.ibm.tx.jta.RecoveryManager.run(RecoveryManager.java:2200)
at java.lang.Thread.run(Thread.java:735)

Solution
1. Shut down WAS(WebSphere Application Server) V7

2. Change directory to transaction logs foldler: [WebSphere Application Server_install_root]\profiles\[PROFILE_NAME]\tranlog\[CELL_NAME]\[NODE_NAME]\[SERVER_NAME]\transaction


3. Delete all folder and files

4. Start up server again

5. Do not have error message any more

6. And log into admin console successfully.

2011/03/03

如何在Word中建立書籤及超連結

建立書籤與超連結

1. 將要做書籤的文字進行反白

2. 插入-->書籤

3. 輸入書籤名稱-->新增


4. 把要做超連結的文字進行反白

5. 按下書籤按鈕

6. 選擇剛剛建立的書籤 --> 確定



測試

1. 點選超連結


2. 正確連結到該頁面,大成功!

2011/01/31

RSA Error: 需要管理員權限,請嘗試『以系統管理員身分執行』。

Scenario
I got this error message "需要管理員權限,請嘗試『以系統管理員身分執行』。" when I launch IBM Installation Manager.


Solution

2011/01/28

Rational Software Architect (RSA) 7.5 for WebSphere Installation

Install IBM Installation Manager

Welcome Page, Click Next

Choose I accept agreement...., and Click Next

Click Next

Click Install

Downloading....

Finish


Install Rational Software Architect (RSA 7.5) and WebSphere Application Server 7.0

Enter welcome page, and click Next

Downloading jar files

Select I accept agreement, and Click Next

Click Next

Click Next

Click Next

Click Next

Select the plug-ins which you need to install

Click Next

Click Next

Click Install

downloading jar files

As it download all selected jar files, then the installation process was well done.

Before you startup RSA, remember to edit eclipse.ini to allocate more memory to RSA.