After you create IMS Java data bindings, you need to create a Java
bean that communicates with IMS through the J2EE Connector Architecture.
This Java bean includes a method that submits a request to IMS to
run the IMS transaction. This method uses the Java data bindings to build
the input and output messages for the transaction. A J2C Java bean may include
more than one method that runs an IMS transaction, as well as multiple data
bindings for different input and output messages. The code that is generated
for the J2C Java bean uses the CCI provided by the IMS resource adapter to
communicate with IMS.
To create a J2C Java bean that runs an IMS transaction,
complete the following steps:
- To start the J2C dynamic wizard, from the menu bar, select File
> New > Other > J2C.
- Expand the J2C folder, select J2C Java bean,
and click Next.
- In the Resource Adapters Selection page, select the version of
the IMS resource adapter that you wish to use. You may select either
the JCA 1.0 IMS resource adapter, IMS Connector for Java (IBM:
9.1.0.1.1) or the JCA 1.5 IMS resource adapter, IMS
Connector for Java (IBM : 9.1.0.2).
- Click Next.
- In the Connection Properties page, select the Managed checkbox.
Note: There are two options for the way in which connections are
created between the IMS resource adapter, as used by your Java bean, and IMS
Connect. This example is not a two-tiered application, so only a managed connection
is applicable.
- Managed connections are created by a construct of the J2EE Connector Architecture
called a connection factory and are managed by the application server. Your
Java bean accesses a connection factory using JNDI (Java Naming and Directory
Interface). Managed connections are recommended. The IMS resource adapter
and the application server's connection manager work together to efficiently
manage connections by providing connection pooling, reuse, and persistence.
- Non-managed connections are obtained directly through the IMS resource
adapter, without collaboration with the application server. Non-managed connections
are typically used by two-tiered applications, and are not pooled or reused.
In addition, non-managed socket connections between the IMS resource adapter
and IMS Connect are not persistent, incurring the additional overhead of opening
and closing the socket for each use by an application.
- On the Connection Properties page, next to the JNDI lookup name
field, click New. This defines a new server
instance. To define a new server instance, the resource adapter you selected
in Step 3, is deployed to the server instance. To create a new server instance
in your workspace, complete the following steps:
- In the JNDI Lookup wizard, on the Server instance selection
page, select New.
- In the Define a New Server page, select the type of server you
wish to create; for example, WebSphere 6.0 Server.
Then, click Next.
- In the WebSphere Server Settings page, accept the defaults.
- Click Finish. The resource adapter you
selected in Step 3 is deployed to your server instance.
- On the Server instance selection page, click Next.
- Create and configure a J2C connection factory for the server instance
you just created. The J2C Connection Factories wizard allows you
to select a J2C connection factory from those that have been defined for the
resource adapter you selected in Step 3. You can also provide the JNDI lookup
name of a connection factory that does not yet exist and define it later.
To create and configure a J2C connection factory for your server instance,
complete the following steps:
- In the J2C Connection Factory page, enter a JNDI name for your
new connection factory. For example, imsCFac.
- Configure your connection factory. For TCP/IP connections to
IMS Connect, at minimum, provide values for the following fields:
- In the Host name: field, enter the TCP/IP hostname
of the IMS Connect that your application will use. For example: MYHOST.MYCOMPANY.COM
- In the Port number: field, enter the port number.
For example, 9999.
- In the Data store name: field, enter the target
IMS datastore. For example, IMSA.
- Click Finish. The server
instance is started and initialized.
- After you have configured your server instance and your server
has started, the JNDI name of the connection factory appears in the JNDI Lookup
name field. Click Next.
- In the J2C Java Bean Output Properties page, complete the following
steps:
- For the Java Project Name , click New.
- Select Java project as the project type,
and click Next.
- In the Create a Java project page, type PhoneBookJ2CBean for
the new Java project name, accept all other defaults, and then click Finish.
- Next to Java Package Name, click New.
- In the Java Package page, type sample.ims for
the new Java package name and click Finish.
- For the Interface Name, specify PB.
- For the Binding Name, accept the default of PBImpl.
- Click Next.
- To create a method that runs the transaction, use the Java Methods
wizard and complete the following steps:
- Click Add to add a Java method to your
J2C Java bean.
- In the Add Java Method page, type runPB for
the Java method name, the click Next.
- On the Java Method page, click Browse next
to the Input type field.
- In the Select a data type window, prime the entry field with
an asterisk (*) to view the available data types.
- In the Matching types field, select INPUTMSG and
click OK to use the INPUTMSG data binding for the method, runPB.
- Next to the Output type field, click Browse.
- In the Select a data type window, prime the entry field with
an asterisk (*) to view the available data types.
- In the Matching types field, select OUTPUTMSG and
then click OK to use the OUTPUTMSG data binding for
the method, runPB.
- Click Finish.
- The Java Methods wizard displays the new method, runPB (INPUTMSG
: OUTPUTMSG) in the list of methods for the Java bean. Ensure that this
method is selected.
- In the InteractionSpec properties for 'runPB', specify the IMSInteractionSpec
values. For this example, accept all defaults, then click Finish.
You now have a J2C Java bean in project, PhoneBookJ2CBean, that you
can deploy in one or more J2EE applications using different J2EE resources.