Applications using the CCI have a common structure, independent of the
EIS that is being used. The JCA defines Connections and ConnectionFactories
which represent the connection to the EIS. These objects allow a J2EE application server to
manage security, transaction context, and connection pools for the resource
adapter.
An application must start by obtaining a ConnectionFactory from which a
Connection can be obtained. The properties of this Connection can be overridden
by a ConnectionSpec object. The ConnectionSpec class is CICS-specific, so
may be either an ECIConnectionSpec or an EPIConnectionSpec.
After an connection has been obtained, an Interaction can be created from
the Connection in order to make a particular request. As with the Connection,
Interactions can have custom properties set by the CICS-specific InteractionSpec
class (ECIInteractionSpec or EPIInteractionSpec). To perform the Interaction,
call the execute() method and use CICS-specific Record objects to hold the
data. For example:
Obtain a ConnectionFactory
Connection c = cf.getConnection(ConnectionSpec)
Interaction i = c.createInteraction()
InteractionSpec is = newInteractionSpec();
i.execute(spec, input, output)
The ConnectionFactory can be obtained
in two ways:
- If you are using a J2EE application server, the ConnectionFactory is normally created
from the resource adapter by means of an administration interface. This ConnectionFactory
has custom properties set for it, for example the Gateway to be used would
be set as a ConnectionURL. When the ConnectionFactory has been created, it
can be made available for use by any enterprise applications through JNDI.
This type of environment is called a managed environment. A managed environment
allows a J2EE application server to manage the qualities of service of the connections. Refer
to the Administration Guide for a description of deployment into a managed
environment.
- If you are not using a J2EE application server, you must create a ManagedConnectionFactory
and set its custom properties. You can then create a ConnectionFactory from
the ManagedConnectionFactory. This type of environment is called a non-managed
environment. A non-managed environment does not allow a J2EE application server to manage
connections.