Answer Posted / kiran
Creating a J2C bean to connect to IMS
After you create IMS™ Java data bindings, you need to
create a Java bean that communicates with IMS through the
J2EE Connector Architecture.
About this task
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 bean can 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 bean uses the CCI
provided by the IMS TM Resource Adapter to communicate with
IMS.
Procedure
To start the J2C dynamic wizard, from the menu bar, select
File > New > Other > J2C.
Expand the J2C folder, select J2C bean, and click Next.
In the Resource Adapters Selection page, select the version
of the IMS TM Resource Adapter that you want to use. You
can select either IMS Connector for Java (IBM: 10.5.x) or
IMS Connector for Java (IBM: 11.3.0), and click Next.
In the Connection Properties page, select Managed.
Note: There are two options for the way in which
connections are created between the IMS TM 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 TM
Resource Adapter and the connection manager of the
application server work together to manage efficiently the
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 TM 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 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 want to create; for example, WebSphere 7.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 created. The J2C Connection Factories
wizard allows you to select a J2C connection factory from
the ones 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 host name 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 data
store. 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 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 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.
Results
You now have a J2C bean in project, PhoneBookJ2CBean, that
you can deploy in one or more Java EE applications using
different Java EE resources.
Feedback
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Can beans who are involved in transaction have 'passivation' process?
What is mdb?
What is EJB object?
What is ejb in weblogic?
Enlist the contents of Container.
How does ejb invocation take place?
Is it possible to write two ejb’s that share the same remote and home interfaces, and have different bean classes? If so, what are the advantages/disadvantages?
What is ejb bean in java?
What do you mean by re-entrant? Can you say that session beans as re-entrant? Can entity beans be specified as re-entrant?
What is ejb and its types in java?
What is ejb role in j2ee?
Is ejb a framework?
How many ejb objects are created for a bean?
What do you understand by session facade?
What is passivation and activation in ejb?