164 CCF-to-J2C Architecture Migration
The following section discusses the code that is needed to set up the desired
QoS for an IMS CCF application in a non-managed environment.
8.1.5 Setting up the QoS for a sample IMS CCF application
This section describes a sample application in which the Quality of Services of
connection pooling, transaction support, and security are set up for a simple IMS
CCF application.
This example is a catalogue Web application that handles orders and an item
inventory. The application has a servlet Web layer that uses proxy classes to
drive the back-end interaction. The methods of these classes manage the
desired function by interacting with IMS using the appropriate EAB command.
There are also specialized classes that are used to manage and set up the
desired QoS by the application components. The following application
components are described in detail:
The method itemDetail() of the proxy class ItemHandler
The class IMSBOManager that handles the setup of a specialized
JavaRuntimeContext with the desired QoS
The helper class IMSConnectionManager that prepares the common
ConnectionManager and loads the ConnectionSpec, InteractionSpec, and
LogonInfo properties
The Item bean that represents the item entity
The itemDetail() method in the ItemHandler class loads the input record, makes
the call to IMS, and analyzes the output record. Referring to the
ItemHandler.itemDetail() code in Example 8-1 on page 165:
1a The IMSBOManager.initializeContext() method is called. It sets up the
JavaRuntimeContext associated with the current thread with the desired QoS
(connection pooling, transaction, and security).
2a The EAB command is initialized and the RuntimeContext is bound to the
current JavaRuntimeContext.
3a The static method IMSConnectionManager.initializeIMSCommand() loads
the IMSConnectionSpec, IMSInteractionSpec, and IMSLogonInfoItems
objects with the appropriate properties, read in from a properties file.
4a The input record is instantiated and loaded with the appropriate values.
Important: in a managed environment, the application server manages the
QoS. In a non-managed environment, the application components have to
manage the QoS.
Chapter 8. Comparing CCF to J2C Architecture 165
5a The call to IMS is executed.
6a The output record is retrieved and type casted.
7a If the desired output record has been obtained, then it is passed to a
custom Mapper class that loads the Item class.
8a If the desired output record is not obtained, the DFS error message is
handled. (DFS is a component ID assigned to IMS; it is not an acronym.)
9a In both cases, the current RuntimeContext resources are released with a
logical commit.
10a In case an exception is cached (for example, if the time-out interval is
exceeded), resources are released with a logical rollback.
Example 8-1 Method ItemHandler.itemDetail()
public Item itemDetail(String companyCode, String itemCode)
throws Exception {
Item item = new Item();
RuntimeContext rt = null;
try{
// Runtime context initialization method 1a
initializeContext();
// Get an instance of the related EAB command 2a
ItemDetailCommand cmd = new ItemDetailCommand();
// Get the current RuntimeContext, that is
// the JavaRuntimeContext set in step 1
rt = RuntimeContext.getCurrent();
// Initialization of ConnectionSpec, InteractionSpec and LogonInfo 3a
IMSConnectionManager.initializeIMSCommand(cmd, rt.getLogonInfo());
// Get the input record from the command 4a
ItemDetailInRecord recordInput = cmd.getCeInput();
// Load the input record fields
recordInput.setWS__INP__LL((short)26);
recordInput.setWS__INP__TRANSACTION("UAMBPD01");// IMS Transaction name
recordInput.setWS__INP__COMP__CODE(companyCode);
recordInput.setWS__INP__ITEM__CODE(itemCode);
// Make the call to IMS 5a
166 CCF-to-J2C Architecture Migration
cmd.execute();
// Get the output record and the DFSMsg 6a
ItemDetailOutRecord recordOutput = cmd.getCeOutput0();
DFSMsg error = cmd.getCeOutput1();
// Get the output record
Object o = cmd.getOutput();
// Check if we’ve obtained the desired output record or a DFS error
if ( java.beans.Beans.isInstanceOf(o, ItemDetailOutRecord.class))
{
// We have the desired output record 7a
// Get an instance of the related Mapper class
ItemDetailMapper mapper = new ItemDetailMapper() ;
// Map the output record to the item bean
item = mapper.mapFromOutput(recordOutput);
// Free the resources pooled to the current thread (no IMS call) 9a
commit();
}
else
{
// We have a DFS Error Message record 8a
// Free the resources pooled to the current thread (no IMS call) 9a
commit();
//Handle the DFS error message in the preferred way
}
}
// Something unexpected happened, i.e. IMS connection timeout exeeded 10a
catch (Exception e){
// Free the resources pooled to the current thread (no IMS call)
rollback();
// Handle the exception in the preferred way
}
return item;
}
Get CCF-to-J2C Architecture Migration 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.