Developing applications using the JCA programming interface

JCA connects enterprise information systems such as CICS®, to the JEE platform.

JCA supports the qualities of service for security credential management, connection pooling and transaction management, provided by the JEE application server. Using JCA ensures these qualities of service are managed by the JEE application server and not by the application. This means the programmer is free to concentrate on writing business code and need not be concerned with quality of service. For information about the provided qualities of service and configuration guidance see the documentation for your JEE application server. JCA defines a programming interface called the Common Client Interface (CCI). This interface can be used with minor changes to communicate with any enterprise information system.

The programming interface model

Applications that use the CCI have a common structure for all enterprise information systems. TThe Java™ EE Connector Architecture (JCA) connects the enterprise information systems (EIS) such as CICS, to the JEE platform. These connection objects allow a JEE application server to manage the security, transaction context and connection pools for the resource adapter. An application must start by accessing a connection factory from which a connection can be acquired. The properties of the connection can be overridden by a ConnectionSpec object. After a connection has been acquired, an interaction can be created from the connection to make a particular request. The interaction, like the connection, can have custom properties that are set by the InteractionSpec class. To perform the interaction, call the execute() method and use record objects to hold the data. For example:
 ConnectionFactory cf = <Lookup from JNDI namespace>
 Connection c = cf.getConnection(ConnectionSpec)
 Interaction i = c.createInteraction()
 InteractionSpec is = newInteractionSpec();
 i.execute(spec, input, output)
 i.close();
 c.close();
The example shows the following sequence:
  1. Use the ConnectionFactory object to create a connection object.
  2. Use the Connection object to create an interaction object.
  3. Use the Interaction object to run commands on the enterprise information system.
  4. Close the interaction and the connection.

If you are using a JEE application server, you create the connection factory by configuring it using the administration interface of the server. In the Liberty server this is defined through the server.xml configuration. When you have created a connection factory, enterprise applications can access it by looking it up in the JNDI (Java Naming Directory Interface). This type of environment is called a managed environment, and allows a JEE application server to manage the qualities of service of the connections. For more information about managed environments see your JEE application server documentation.

Record objects

Record objects are used to represent data passing to and from the EIS. It is advised that application development tools are used to generate these Records. Rational Application Developer provides the J2C tooling that allows you to build implementations of the Record interface from specific native language structures such as COBOL copybooks, with in-built support for data marshalling between Java and non-Java data types. 

Resource adapter example

You can install a basic example resource adapter and configure instances of the resources it provides, see Configuring and deploying a basic JCA Resource Adapter in WebSphere Application Server product documentation.

The Common Client Interface

The CCI provides a standard interface that allows developers to communicate with any number of EISs through their respective resource adapters, using a generic programming style. The CCI is closely modeled on the client interface used by Java Database Connectivity (JDBC), and is similar in its idea of Connections and Interactions.