Coding services

The following two dummy services having the same behavior (from the application's point of view) as the real ones have been implemented in order to test and debug the application in a simplified environment:

These services implement the same interface as the real services, and the application refers to them using this interface (and not their class names), so that it is possible to exchange dummy services for real services by changing the entity definition files without modifying the application itself.

The Dummy Lu0 Connector is a Resource Adaptor which only provides the CCI interface. The real Lu0 Connector provides both CCI interface and WSIF interface (plugin). The dummy Connector uses the response.res file to simulate the host data.

The following the sample code to use the DummySnaLu0 service:

javax.naming.Context initialContext = null;
ConnectionFactory connectionFactory = null;

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"));
System.out.println("data to host: : "+in.getData());

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());
System.out.println("SendHost ok");