188 CCF-to-J2C Architecture Migration
(Figure 8-11 on page 187). This prevents the service client from having to bind
objects specific to a given service provider.
For a detailed description of enterprise services migration using WebSphere
Studio 5.1, refer to Chapter 4, “Manual migration” on page 39.
8.3.4 Setting up the QoS for an IMS J2CA/WSIF application
The following steps describe the CCF/EAB code sample shown in 8.1.4,
“Implementing the QoS with the RuntimeContext” on page 162, implemented
using J2CA and WSIF instead of the CCF (shown in Example 8-1 on page 165):
򐂰 1 The input message is instantiated.
򐂰 2 The input message is loaded with the appropriate attributes.
򐂰 3 The EJB service proxy is instantiated.
򐂰 4 The input message is set in the proxy.
򐂰 5 The proxy makes the call to IMS.
򐂰 6 The proxy returns an instance of the output message.
򐂰 7 The custom Mapper class is instantiated.
򐂰 8 The item bean instance is loaded by the mapper.
򐂰 9 A generic WSIFException is caught and a more specific target exception is
extracted to allow for proper error handling.
򐂰 10 IMS returns a DFS fault message.
򐂰 11 The IMS Resource Adapter returns an exception.
򐂰 12 A generic exception is caught (for example, if the time-out interval is
exceeded).
Example 8-5 New J2CA/WSIF implementation of Method ItemHandler.itemDetail()
public Item itemDetail(String companyCode, String itemCode)
throws Exception {
Item item = new Item();
try {
// Instantiate the input message 1
ItemDetailInRecord recordInput = new ItemDetailInRecord();
// Load the input record fields 2
recordInput.setWs__inp__ll((short) 26);
recordInput.setWs__inp__transaction("UAMBPD01");// Transaction name
recordInput.setWs__inp__company__code(companyCode);
Chapter 8. Comparing CCF to J2C Architecture 189
recordInput.setWs__inp__item__code(itemCode);
// Instantiate the EJB proxy 3
ItemDetailCommandProxy proxy = new ItemDetailCommandProxy();
// Set the input message to the proxy 4
proxy.setItemDetailInRecord(recordInput);
// Invoke the proxy’s execute() method to interact with IMS 5
proxy.execute();
// Get the output record 6
ItemDetailOutRecord recordOutput =
proxy.getItemDetailOutRecordOutputPart();
// We have the desired output record
// Get an instance of the related Mapper class 7
ItemDetailMapper mapper = new ItemDetailMapper();
// Map the output message to the related bean 8
item = mapper.mapFromOutput(recordOutput);
} catch (Exception e) {
if (e instanceof org.apache.wsif.WSIFException) {
//Gather more information on the exception thrown 9
Throwable throwableException = ((org.apache.wsif.WSIFException)
e).getTargetException();
if (throwableException instanceof IMSDFSMessageException) {
// DFS Messages are handled as an exception 10
// Handle the exception in the preferred way
} else {
// IMS Connector (RA) thrown an exception 11
// Handle the exception in the preferred way
}
} else {
// Generic Exception, i.e. IMS connection timeout exeeded 12
190 CCF-to-J2C Architecture Migration
// Handle the exception in the preferred way
}
}
return item;
}
Note the following regarding Example 8-5 on page 188:
򐂰 There is an absence of code for QoS handling. This is handled by the
managed environment provided by WebSphere Application Server 5.x.
򐂰 QoS matters are decoupled from the call to the EIS (IMS).
The EJB proxy and the I/O messages have been generated from the WSDL
definition of the IMS Enterprise Service, using WebSphere Studio 5.x wizards
without having to manually develop code (refer to Chapter 4, “Manual migration”
on page 39).

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.