J2EE Connector Architecture resource adapters


WAS supports any resource adapter that implements version 1.0 of the J2EE Connector Architecture (JCA) specification. Although not part of WAS, IBM supplies resource adapters for enterprise systems such as:

  1. Customer Information Control System (CICS)
  2. Host On-Demand (HOD)
  3. Information Management System (IMS)
  4. Systems, Applications, and Products (SAP) R/3

The general approach to writing an application that uses a JCA resource adapter is to develop session beans that use the javax.resource.cci interfaces to communicate with an enterprise information system through the resource adapter.


Accessing data using J2EE Connector Architecture connectors

As indicated in the J2EE Connector Architecture (JCA) Specification, each enterprise information system (EIS) needs a resource adapter and a connection factory. This connection factory is then accessed through the following programming model. If you use WebSphere Studio Application Development (WSAD) tools, most of the following deployment descriptors and code are generated for you. This example shows the manual method of accessing an EIS resource.

For each EIS connection, do the following...

  1. Declare a connection factory resource reference in your application component's deployment descriptors, as described in this example


  2. Configure, during deployment, each resource adapter and associated connection factory through the console. See Configuring J2C resource adapters and Configuring J2C connection factories for more information.

  3. Locate the corresponding connection factory for the EIS resource adapter using JNDI lookup in your application component, during run time.

  4. Get the connection to the EIS from the connection factory.

  5. Create an interaction from the Connection object.

  6. Create an InteractionSpec object. Set the function to execute in the InteractionSpec object.

  7. Create a Record instance for the input and output data used by function.

  8. Execute the function through the Interaction object.

  9. Process the record data from the function.

  10. Close the connection.


Usage Scenario

The following code segment shows how an application component might create an interaction and execute it on the EIS

javax.resource.cci.ConnectionFactory connectionFactory = null;
javax.resource.cci.Connection connection = null;
javax.resource.cci.Interaction interaction = null;
javax.resource.cci.InteractionSpec interactionSpec = null;
javax.resource.cci.Record inRec = null;
javax.resource.cci.Record outRec = null;

try {
// Locate the application component and perform a JNDI lookup
   javax.naming.InitialContext ctx = new javax.naming.InitialContext();
   connectionFactory = (javax.resource.cci.ConnectionFactory)

// create a connection
   connection = connectionFactory.getConnection();

// Create Interaction and an InteractionSpec
   interaction = connection.createInteraction();
   interactionSpec = new InteractionSpec();

// Create input record
   inRec = new javax.resource.cci.Record();

// Execute an interaction
   interaction.execute(interactionSpec, inRec, outRec);

// Process the output...

} catch  Exception(e) {
   // Exception Handling
finally {
    if (interaction != null) {
         try {
         catch  Exception(e) {/* ignore the exception*/}
   if (connection != null) {
        try {
        catch  Exception(e) {/* ignore the exception */}