Chapter 6. Post-migration activities 163
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 the code in Example 6-10.
Example 6-10 Additional code for depositServerOp.snippets.state2 execute() method
try{
javax.naming.Context initialContext = null;
ConnectionFactory connectionFactory = null;
if (initialContext == null) {
initialContext = new javax.naming.InitialContext();
connectionFactory = (ConnectionFactory)
initialContext.lookup("snalu0");
}
// START TRANSACTION
long begin = System.currentTimeMillis();
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());
164 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
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("depositRecFmt");
//$NON-NLS-1$
fromHost.unformat(out.getData(),getContext());
}catch(Exception e){
e.printStackTrace();
}
Change "return 0" to" return 1".
For depositServerOp.snippets.state3, add the import class code in
Example 6-11 on top:
Example 6-11 Import class code for depositServerOpsnippets.state3
import com.ibm.btt.services.jdbcjournalservice.JDBCJournal;
import com.ibm.btt.services.jdbcjournalservice.Journal;
In execute() method add code in Example 6-12.
Example 6-12 Additional code for depositServerOpsnippets.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 complete 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.
9. Modify the BPEL file for depositServerOp business process.
a. Find the package named depositServerOp, and double-click
depositServerOp.bpel to edit.
b. Select depositServerOp. Its properties are displayed in the lower panel.
Select Environment, change the ContextMode to remote, and add
Chapter 6. Post-migration activities 165
"TrxReplyCode, AccountBalance, TrxErrorMessage" to the MapList. See
Figure 6-38.
In the editor, select initial Implementation. Delete the second line
of the code.
In the same way, select state2 Implementation. Delete the second
line of the code.
Save and close the depositServerOp.bpel file.
Figure 6-38 Modify environment property
166 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
10.Modify the *.wsdl file for the depositServerOp business process.
In the same package, open depositServerOpInterface.wsdl with Source
Editor. Add two new lines in the message tag named InputMessage, as in
Example on page 166.
<part name="Amount" type="xsd:string" />
<part name="AccountNumber" type="xsd:string" />
The result should look as follows:
<message name="InputMessage">
<part name="systemData" type="xsd1:BTTSystemData"/>
<part name="Amount" type="xsd:string" />
<part name="AccountNumber" type="xsd:string" />
</message>
Save and close depositServerOpInterface.wsdl..
11.Implement the snippets for the withdrawalServerOp business process.
Expand the BaseSampleProcess project, and find the package named
withdrawalServerOp.snippets. Edit three Java files inside: initial.java,
state2.java, and state3.java.
For withdrawalServerOp.snippets.initial, add the import class code in
Example 6-13 on top.
Example 6-13 Added import code for withdrawalServerOp.snippets.initial.java
import com.ibm.btt.base.Context;
import com.ibm.btt.formatter.client.FormatElement;
import com.ibm.btt.server.flow.al.workarea.BPWorkArea;
import com.ibm.btt.services.jdbcjournalservice.JDBCJournal;
import com.ibm.btt.services.jdbcjournalservice.Journal;
import com.ibm.websphere.workarea.UserWorkArea;
In the execute() method, add the code in Example 6-14.
Example 6-14 Code for execute() method of withdrawalServerOp.snippets.initial.java
try{
if(getContext().getParent()==null)
//getContext().chainTo(Context.getContextNamed("javaSessionCtx"));
getContext().chainTo(Context.getContextByInstanceID(getSystemData().getInst
anceId()));
// JDBCJournal journal;
Journal journal;
Chapter 6. Post-migration activities 167
setValueAt("HostBuff",((FormatElement)getFormat("withdrawalSendFmt")).forma
t(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();
System.out.println("Withdrawal : executeJournalHostRequestDataStep
ok!");
} catch(Exception e){
e.printStackTrace();
}
Change "return 0" to" return 1";
For withdrawalServerOp.snippets.state2, add the needed import class code
in Example 6-15 on top:
Example 6-15 Added import class code for withdrawalServerOp.snippets.state2
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 the execute() method, add the code in Example 6-16:
Example 6-16 Additional code for withdrawalServerOp.snippets.state2 execute() method
try{
javax.naming.Context initialContext = null;
ConnectionFactory connectionFactory = null;
if (initialContext == null) {
initialContext = new javax.naming.InitialContext();
connectionFactory = (ConnectionFactory)
initialContext.lookup("snalu0");
}
// START TRANSACTION
long begin = System.currentTimeMillis();

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.