66 CCF-to-J2C Architecture Migration
Example 5-7 Call to IMS using J2CA-generated code
MessageIn input = new MessageIn();
input.setMi__rejected("X");
input.setMi__approved("");
//populate the input class
...
ImsServiceProxy proxy = new ImsServiceProxy();
proxy.setMessageIn(input);
proxy.execute();
MessageOut output = proxy.getMessageOutPart();
If the call to IMS fails, the application server rolls back the updates to IMS as
well as updates to other resources (for example, updates to a database).
5.2 Post-migration steps for automatically converted
applications
In this section, we discuss certain application client code changes, beyond those
mentioned above, that are necessary if you have migrated the CCF artifacts
using the CCF Migration Assistant.
5.2.1 Command compatibility
The CCF Migration Assistant, as part of the postprocessing, inserts the following
methods in the service proxies for compatibility with Command beans. Modify the
application client code to use the public execute methods of the service proxies
instead of the execute methods of the Command beans.
public void execute() throws org.apache.wsif.WSIFException
public WSIFMessage execute(WSIFMessage aMessage) throws
WSIFException, Exception
Apart from the above methods, the CMA would optionally insert the setInput and
getOutput methods into the WebSphere Studio generated service proxies, if
desired by the user. See 3.6, “Migrating CCF artifacts to J2CA artifacts using
CMA” on page 31 for instructions on choosing this option. This option has been
provided to help minimize client code changes for applications that use the CCF
setInput and getOutput methods.
Chapter 5. Post-migration steps 67
The inserted setInput and getOutput methods essentially map directly to the
specific methods generated by the standard WebSphere Studio tooling. Note that
the generated methods are deprecated. While these methods provide limited
backward compatibility for existing CCF code, they should
not be relied on for
long-term application development and should be removed as early in the cycle
as possible. The application client must be modified to use the following
methods, which are inserted into the service proxy.
public void setCeInput(com.xxx.yyy.zzzRecord record)
public void setInput(Object input)
public com.xxx.yyy.zzzRecord getCeOutput0( )
public Object getOutput( )
public Object getInput( )
public com.xxx.yyy.zzzRecord getCeInput( )
Example 5-8 shows an example of a CCF application that creates an input record
object, executes the command, and gets the output record object.
Example 5-8 Executing a command in a CCF application
// Get an instance of the related EAB command
ItemDetailCommand cmd = new ItemDetailCommand();
// Get the current RuntimeContext, that is
...
// Initialization of ConnectionSpec, InteractionSpec and LogonInfo
...
// Create an input record for the command
ItemDetailInRecord recordInput = new ItemDetailInRecord();
// Fill the input record fields
recordInput.setWS__INP__LL(26);
...
// Set the input record
cmd.setCeInput(recordInput);
// Call the EAB command execute method on IMS
cmd.execute();
// Get the output record
Object o = cmd.getOutput();
Example 5-9 on page 68 shows the same application after migration to J2CA
using CMA with this option: Generate getInput and getOutput methods for the
service proxies. Note that no application client code change was required.
Restriction: getOutput will not be generated for multiple output commands;
for those, only getCeOutputn methods will be generated.
68 CCF-to-J2C Architecture Migration
Example 5-9 J2CA application using the compatibility methods
// Get an instance of the service proxy
ItemDetailCommand cmd = new ItemDetailCommand();
// Create an Input Data bean
ItemDetailInRecord recordInput = new ItemDetailInRecord();
// Fill the input data bean fields
recordInput.setWS__INP__LL(26);
...
// Set the input data bean
cmd.setCeInput(recordInput);
// Call the execute method on the service proxy
cmd.execute();
// Get the output data bean
Object o = cmd.getOutput();
If you do not want to generate or use the setInput( ) and getOutput( )
methods, you must modify your application client to invoke the service proxy’s
setter and getter methods for the input and output data beans respectively
(Example 5-10).
Example 5-10 J2CA application without the compatibility methods
// Get an instance of the service proxy
ItemDetailCommand cmd = new ItemDetailCommand();
// Create an Input Data bean
ItemDetailInRecord recordInput = new ItemDetailInRecord();
// Fill the input data bean fields
recordInput.setWS__INP__LL(26);
...
// Set the input message
cmd.setItemDetailCommandRequestPart(recordInput);
// Call the execute method on the service proxy
cmd.execute();
// Get the output message
ItemDetailOutRecord recordOutput = cmd.getItemDetailCommandResponsePart();
Also, com.ibm.ivj.eab.command.CommunicationCommand is not valid in a
J2CA environment. All occurrences of
com.ibm.ivj.eab.command.CommunicationCommand and
com.ibm.ivj.eab.command.Command should be replaced with Object.
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.