Chapter 6. Post-migration activities 153
Figure 6-33 Generate deployment code
6.4 Adding and modifying code
In this section we describe some of the code additions and modifications you
must make to successfully complete the migration.
6.4.1 Business logic layer
This section describes how the business logic layer needs to be altered in order
to complete the migration.
Configuring the business process
To configure the business process, follow these steps:
1. Open the application.xml file in the META-INF folder of the BaseSample
project in J2EE perspective. In the Module tab, click Add to include following
modules:
BTTCHAEJB
BTTCHAWeb
154 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
BTTFormatterEJB
bttsvcinfra
BTTServiceInfraWeb
DSE_SampleApplicationClient
2. Click Add in the lower panel to add Project Utility JARs. Select
UserDefineJar and BaseSampleProcess project separately. Save and
close the file. See Figure 6-34.
Figure 6-34 Add utility JARs
3. Right-click the BaseSampleProcess project. In the pop-up menu, select
New Package to create a package named
com.ibm.btt.samples.services. Then create two Java classes named
DummyJournal and DummyJournalImpl in that package. See the source code in
Chapter 6. Post-migration activities 155
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.
4. Right-click the BaseSampleProcess project, and in the pop-up menu, select
Properties. Select Java JAR Dependencies, and add the following JARs as
dependencies:
bttbase.jar
bttfmt.jar
bttjdbjsvc.jar
bttjdbtsvc.jar
bttsvcinfra.jar
bttsvrbean.jar
bttsvrflow.jar
–sn0dummy.jar
UserDefineJar.jar
Click OK. See Figure 6-35
Figure 6-35 JAR dependencies
156 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
5. Implement the snippets for the customerSearchServerOp business process.
Expand the BaseSampleProcess project, and find the package named
customerSearchServerOp.snippets. There are three Java files inside:
initial.java, state2.java, and state3.java. Migration Tools only provides
template for these classes. You should implement them depending on their
business logic.
Code modification of initial.java
Add the required import class code in Example 6-1 on top:
Example 6-1 Import class code for initial.java
import com.ibm.btt.base.Context;
import com.ibm.btt.formatter.client.FormatElement;
import com.ibm.btt.services.jdbcjournalservice.Journal;
import com.ibm.dse.samples.appl.HostField;
In execute() method, add this code in Example 6-2:
Example 6-2 Additional code for initial.java execute() method
try{
Context bpContext = getContext() ;
if(bpContext.getParent() == null){
Context parent =
Context.getContextByInstanceID(getSystemData().getInstanceId()) ;
bpContext.chainTo(parent);
}
Journal journal;
String hostBuff =
((FormatElement)getFormat("customerSearchSendFmt")).format(getContext())
;
setValueAt("HostBuff",hostBuff);
// 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".
Code modification of state2.java
Add the required import class code in Example 6-3 on top.
Chapter 6. Post-migration activities 157
Example 6-3 Import class code for state2.java
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 the code in Example 6-4.
Example 6-4 Additional code for state2.java 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();
// 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);

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.