29-03-2012, 01:18 PM
JCA CCI
important20.docx (Size: 24.83 KB / Downloads: 28)
Introduction
J2EE provides a specification to standardize access to enterprise information systems (EIS): the JCA (Java
Connector Architecture). This specification is divided into several different parts:
• SPI (Service provider interfaces) that the connector provider must implement. These interfaces constitute a
resource adapter which can be deployed on a J2EE application server. In such a scenario, the server manages
connection pooling, transaction and security (managed mode). The application server is also responsible for
managing the configuration, which is held outside the client application. A connector can be used without an
application server as well; in this case, the application must configure it directly (non-managed mode).
• CCI (Common Client Interface) that an application can use to interact with the connector and thus
communicate with an EIS. An API for local transaction demarcation is provided as well.
The aim of the Spring CCI support is to provide classes to access a CCI connector in typical Spring style,
leveraging the Spring Framework's general resource and transaction management facilities.
Connector configuration
The base resource to use JCA CCI is the ConnectionFactory interface. The connector used must provide an
implementation of this interface.
To use your connector, you can deploy it on your application server and fetch the ConnectionFactory from the
server's JNDI environment (managed mode). The connector must be packaged as a RAR file (resource adapter
archive) and contain a ra.xml file to describe its deployment characteristics. The actual name of the resource is
specified when you deploy it. To access it within Spring, simply use Spring's JndiObjectFactoryBean to fetch
the factory by its JNDI name.
Using a single CCI connection
If you want to use a single CCI connection, Spring provides a further ConnectionFactory adapter to manage
this. The SingleConnectionFactory adapter class will open a single connection lazily and close it when this
bean is destroyed at application shutdown. This class will expose special Connection proxies that behave
accordingly, all sharing the same underlying physical connection.
Record conversion
One of the aims of the JCA CCI support is to provide convenient facilities for manipulating CCI records. The
developer can specify the strategy to create records and extract datas from records, for use with Spring's
CciTemplate. The following interfaces will configure the strategy to use input and output records if you don't
want to work with records directly in your application.
Modeling CCI access as operation objects
The org.springframework.jca.cci.object package contains support classes that allow you to access the EIS
in a different style: through reusable operation objects, analogous to Spring's JDBC operation objects (see
JDBC chapter). This will usually encapsulate the CCI API: an application-level input object will be passed to
the operation object, so it can construct the input record and then convert the received record data to an
application-level output object and return it.