466 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
e. Set the EAR project as BTTBank, and click Finish. Click OK in the pop-up
window, as shown in Figure 8-192.
Figure 8-192 New BTTBankAppClientWeb
f. Click Finish in the Import Dialog boxto complete the Web Project Import.
g. Right-click the Web project BTTBankAppClientWeb, and select
Properties. In the pop-up window, select Java Build Path in the left
navigation panel, and the Projects tab in the right panel. Check
BTTBankEJB project. Click OK. This step can fix the errors in the
BTTBankAppClientWeb Web project.
2. In J2EE perspective, right-click BTTBankAppClientWeb project, and select
Java Resources. Click New Package to create a package named
withdrawalServerOp.invoker.java.
3. Right-click BTTBankAppClientWeb project and select Java Resources
withdrawalServerOp.invoker.java. Select New Class to create a Java
class named WithdrawalServerOpInvoker which extends the super class
com.ibm.btt.cs.invoker.base.BeanInvokerImpl and implements the interface
Running H/F 1 467
com.ibm.btt.cs.invoker.base.BeanInvokerForJavaRequest, as shown in
Figure 8-193.
Figure 8-193 New class WithdrawalServerOpInvoker
4. Add code to class WithdrawalServerOpInvoker.java.
a. Add import class as shown in Example 8-50.
Example 8-50 Import class of WithdrawalServerOpInvoker
import com.ibm.btt.base.Context;
import java.util.Hashtable;
import javax.ejb.EJBHome;
import com.ibm.btt.base.BTTSystemData;
import com.ibm.btt.base.Constants;
import com.ibm.btt.base.DSEInvalidArgumentException;
import com.ibm.btt.base.DSEInvalidRequestException;
import com.ibm.btt.base.DSEObjectNotFoundException;
468 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
import com.ibm.btt.cs.invoker.base.*;
import com.ibm.btt.cs.servlet.CSConstants;
import javax.naming.InitialContext;
import btt.bank.business.logic.*;
b. Add code to the method parseRequestData(String arg0), which uses
BeanInvokerFormatter instance to unformat the request data and put the
result into a hashtable, as shown in Example 8-51.
Example 8-51 WithdrawalServerOpInvoker.parseRequestData()
try {
//** Prepare session data in ejb parameters
getEjbParameters().put(Constants.SESSION_ID,
getSystemData().getSessionId());
getEjbParameters().put(CSConstants.DATAAPPLICATIONIDKEY,
getSystemData().getSubsessionId());
//** Get BranchId value from request data
Tokenizer tokens = getDelimitedTokenizer(arg0); //The arg0 is request data
BeanInvokerFormatter formatter = getFormatter();
String s = formatter.unformatString((String)tokens.nextToken("#"),null);
getEjbParameters().put("BranchId", s);
//** Get AccountNumber value
s = formatter.unformatString((String)tokens.nextToken("#"),null);
getEjbParameters().put("AccountNumber", s);
//** Get Date value
java.util.Date aDate =
formatter.unformatDate((String)tokens.nextToken("#"),true,"ymd",true,"/");
getEjbParameters().put("Date", aDate);
//** Get Amount value
Float amt = (Float) formatter.unformatFloat((String)tokens.nextToken("#"));
getEjbParameters().put("Amount", amt);
} catch (Exception e) {
throw new DSEInvalidRequestException(Constants.COMPID, "", e.getMessage());
}
c. Add code to the method processRespondData(Object arg0), which uses
BeanInvokerFormatter instance to format the SAE execution result to a
string for client withdrawal operation, as shown in Example 8-52.
Example 8-52 WithdrawalServerOpInvoker.processRespondData()
Hashtable haResult = (Hashtable)arg0;//The arg0 is SAE execution result.
BeanInvokerFormatter formatter = getFormatter();
Running H/F 1 469
//Build a string
String responseString = "";
try {
responseString =
formatter.formatString((String)haResult.get("TrxReplyCode"), null);
responseString = formatter.addDelimiter(responseString, "#");
responseString +=
formatter.formatNumericString((String)haResult.get("AccountBalance"));
responseString = formatter.addDelimiter(responseString, "#");
responseString +=
formatter.formatString((String)haResult.get("TrxErrorMessage"), null);
responseString = formatter.addDelimiter(responseString, "#");
} catch (Exception e) {
throw new DSEInvalidRequestException(Constants.COMPID, "", e.getMessage());
}
return responseString;
d. Add code to the method createBeanInvokerProxy(), which creates an SAE
instance, as shown in Example 8-53.
Example 8-53 WithdrawalServerOpInvoker.createBeanInvokerProxy()
WithdrawalServerOp bean = null;
WithdrawalServerOpHome home = null;
try {
home = (WithdrawalServerOpHome)this.getHomeObject();
bean = (WithdrawalServerOp) home.create();
} catch (Exception e) {
throw new DSEInvalidRequestException(Constants.COMPID, "", e.getMessage());
}
return bean;
e. Add code to the method executeEJB(), which uses the created SAE
instance to execute the method in SAE and get results, as shown in
Example 8-54.
Example 8-54 WithdrawalServerOpInvoker.executeEJB()
WithdrawalServerOp bean = (WithdrawalServerOp) getBeanInvokerProxy();
Hashtable result = (Hashtable)bean.execute(getSystemData(),getEjbParameters());
return result;
f. Save and close the Java Editor for withdrawalServerOpInvoker.
470 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
5. Create a property file named withdrawalServerOpOP.properties in the
package withdrawalServerOp.invoker.java.
a. Right-click BTTBankAppClient Web project, and select Java
Resources withdrawalServerOp.invoker.java package. Click
New Other.
b. In the dialog box, select Simple in the left navigation panel, and File in the
right panel, as shown in Figure 8-194, and click Next.
Figure 8-194 Create a simple file
c. The value in the parent folder field should be
BTTBankAppClientWeb/JavaSource/withdrawalServerOp/invoker/java,

Get IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.