168 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
// For testing Component-managed authentication.
DummyLu0ConnectionSpec lu0ConnectionSpec = new DummyLu0ConnectionSpec();
lu0ConnectionSpec.setUserName("sna");
lu0ConnectionSpec.setPassword("sna");
Connection connection =
connectionFactory.getConnection(lu0ConnectionSpec);
System.out.println("connection created...");
// Beginning of testing SYNC_SEND_RECEIVE
Interaction interaction = connection.createInteraction();
System.out.println("interaction created...");
DummyLu0InteractionSpec interactionSpec = new
DummyLu0InteractionSpec();
DummyLu0Record in = new DummyLu0Record();
DummyLu0Record out = new DummyLu0Record();
in.setData((String) getValueAt("HostBuff"));
interactionSpec.setInteractionVerb(InteractionSpec.SYNC_SEND_RECEIVE);
interactionSpec.setExecutionTimeout(10000);
interaction.execute(interactionSpec, in, out);
System.out.println("data from host: " + out.getData());
interaction.close();
System.out.println("interaction closed...");
connection.close();
System.out.println("connection closed...");
com.ibm.btt.formatter.client.FormatElement fromHost =
(com.ibm.btt.formatter.client.FormatElement) getFormat("withdrawalRecFmt");
//$NON-NLS-1$
fromHost.unformat(out.getData(),getContext());
}catch(Exception e){
e.printStackTrace();
}
Change "return 0" to" return 1".
For withdrawalServerOp.snippets.state3, add the import class code in
Example 6-17 on page 168 on top:
Example 6-17 Import class code for withdrawalServerOp.snippets.state3
Chapter 6. Post-migration activities 169
import com.ibm.btt.services.jdbcjournalservice.JDBCJournal;
import com.ibm.btt.services.jdbcjournalservice.Journal;
In execute() method add the code in Example 6-18.
Example 6-18 Execute() method code for withdrawalServerOp.snippets.state3
try{
Journal journal;
journal = (Journal)getService("JournalService");
journal.addRecord(getContext(), " afterRecJournalFmt ");//$NON-NLS-1$
journal.releaseServiceRequester();
}catch(Exception e){
e.printStackTrace();
}
Change "return 0" to "return 1";
For the source code, refer to Appendix A, “Branch Transformation Toolkit
development and runtime requirements” on page 477 and Appendix B,
“Setting up a Branch Transformation Toolkit sample application” on page 493.
12.Modify the BPEL file for the withdrawalServerOp business process.
Find the package named withdrawalServerOp, and double-click
withdrawalServerOp.bpel to edit.
a. Select withdrawalServerOp. It’s properties are displayed in the lower
panel. Select Environment, and change the ContextMode to remote, also
add "TrxReplyCode, AccountBalance, TrxErrorMessage" to the MapList.
See Figure 6-39 on page 170.
In the editor, select initial Implementation. Delete the second line of
the code.
b. In the same way, select state2 Implementation. Delete the second
line of the code.
c. Save and close the BPEL file.
170 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
Figure 6-39 Modify environment properties for withdrawalServerOp.bpel
13.Modify the wsdl file for the withdrawalServerOp business process.
In the same package, open withdrawalServerOpInterface.wsdl with Source
Editor. Add two new lines in the message tag named InputMessage:
<part name="Amount" type="xsd:string" />
<part name="AccountNumber" type="xsd:string" />
Save and close withdrawalServerOpInterface.wsdl.
14.Implement the snippets for the accountStatementServerOp business
process.
Expand the BaseSampleProcess project, and find the package named
accountStatementServerOp.snippets. Edit three Java files inside, initial.java,
state2.java, and state3.java.
Chapter 6. Post-migration activities 171
For accountStatementServerOp.snippets.initial, add the need to import class
code on top:
import com.ibm.btt.base.Context;
import com.ibm.btt.formatter.client.FormatElement;
import com.ibm.btt.services.jdbcjournalservice.JDBCJournal;
import com.ibm.btt.services.jdbcjournalservice.Journal;
In execute() method add code:
try{
if(getContext().getParent()==null)
//getContext().chainTo(Context.getContextNamed("javaSessionCtx"));
getContext().chainTo(Context.getContextByInstanceID(getSystemData().getInst
anceId()));
Journal journal;
setValueAt("HostBuff",((FormatElement)getFormat("accountStatementSendFmt"))
.format(getContext()));//$NON-NLS-2$//$NON-NLS-1$
// writes to the journal using the appropriate format
journal = (Journal)getService("JournalService");
journal.addRecord(getContext(),"preSendJournalFmt ");//$NON-NLS-1$
journal.releaseServiceRequester();
} catch(Exception e){
e.printStackTrace();
}
Change "return 0" to" return 1".
For accountStatementServerOp.snippets.state2, add the need to import class
code on top:
import java.util.Hashtable;
import javax.resource.cci.*;
import com.ibm.btt.base.*;
import com.ibm.btt.samples.business.sna.lu0.DummyLu0ConnectionSpec;
import com.ibm.btt.samples.business.sna.lu0.DummyLu0InteractionSpec;
import com.ibm.btt.samples.business.sna.lu0.DummyLu0Record;
import com.ibm.btt.services.*;
import com.ibm.btt.services.jdbcjournalservice.Journal;
import com.ibm.btt.formatter.client.FormatElement;
In execute() method add code:
try{
javax.naming.Context initialContext = null;
ConnectionFactory connectionFactory = null;
if (initialContext == null) {
initialContext = new javax.naming.InitialContext();
connectionFactory = (ConnectionFactory)
initialContext.lookup("snalu0");
172 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
}
// START TRANSACTION
long begin = System.currentTimeMillis();
// For testing Component-managed authentication.
DummyLu0ConnectionSpec lu0ConnectionSpec = new
DummyLu0ConnectionSpec();
lu0ConnectionSpec.setUserName("sna");
lu0ConnectionSpec.setPassword("sna");
Connection connection =
connectionFactory.getConnection(lu0ConnectionSpec);
System.out.println("connection created...");
// Beginning of testing SYNC_SEND_RECEIVE
Interaction interaction = connection.createInteraction();
System.out.println("interaction created...");
DummyLu0InteractionSpec interactionSpec = new
DummyLu0InteractionSpec();
DummyLu0Record in = new DummyLu0Record();
DummyLu0Record out = new DummyLu0Record();
in.setData((String) getValueAt("HostBuff"));
interactionSpec.setInteractionVerb(InteractionSpec.SYNC_SEND_RECEIVE);
interactionSpec.setExecutionTimeout(10000);
interaction.execute(interactionSpec, in, out);
System.out.println("data from host: " + out.getData());
interaction.close();
System.out.println("interaction closed...");
connection.close();
System.out.println("connection closed...");
com.ibm.btt.formatter.client.FormatElement fromHost =
(com.ibm.btt.formatter.client.FormatElement)
getFormat("accountStatementRecFmt"); //$NON-NLS-1$
fromHost.unformat(out.getData(),getContext());
}catch(Exception e){
e.printStackTrace();
}
Change "return 0" to" return 1".

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.