Thursday, October 05, 2006

J2EE Connector Architecture - JCA

Why JCA
Enterprise Information Systems (EIS) transact enterprise level information that can be stored in various formats like ERP systems, databases, and mainframe systems. As more organizations move towards Internet-based businesses, integration between applications and these legacy heterogeneous EIS becomes necessary. But most EIS vendors and application server vendors use non-standard vendor-specific architectures to provide connectivity between application servers and EIS.

J2EE Connector Architecture (JCA) defines a standard architecture for connecting J2EE compliant applications to heterogeneous information systems. The architecture can be used to define Resource Adapters, J2EE components that implements the JCA for a specific EIS.


What are Resource Adapters
A Resource Adapter forms the connecting layer between the enterprise application, application server and the EIS. It is a system-level software driver that is used by a Java application server or an application client, to connect to the EIS. A Resource Adapter is specific to the EIS. In literature, resource adapters are also referred to as Connectors.

Some examples of a Resource Adapter are:
A JDBC driver to connect to a relational database
A Resource Adapter to connect to an ERP system
A Resource Adapter to connect to a transaction processing system
Each EIS requires just one implementation of a Resource Adapter which is created as per the JCA specification. Since the implementation is compliant with the JCA, it is portable across all compliant J2EE servers.

What is a Compliant Resource Adapter
Compliance is defined by the following implementation rules specified in JCA version 1.0:

Standard set of system-level contracts between an application server and the EIS. These contracts focus on integration aspects like: connection management, transaction management, and security.
Common Client Interface (CCI) that defines a client API for interacting with multiple EIS.
Standard deployment and packaging protocol for resource adapters.


Implementing JCA
About JCA Contracts
The Connector Architecture provides these contracts:

System contracts between the application server and the resource adapter in the form of connection pooling, transaction, and security.
Application contracts between the client and the resource adapter.
In addition, there is an EIS specific interface between the resource adapter and the EIS.

A resource adapter interacts with a J2EE server with system contracts defined as per the JCA 1.0 specification. These are transparent to the J2EE component. The system contracts link the resource adapter to important services like - connection, transaction, and security. These services are managed by the J2EE server.

The connection management contract supports connection pooling. Connection objects are pooled by the application server. This provides a scalable application environment that can support a large number of clients requiring access to an EIS. Using connection factories, connection is obtained between the application and the EIS through the application server. On receiving a client request, connections are given to the client from the pool. After use, these connections are released by the client and are put back in the connection pool.


The transaction management contract allows an application server to use a transaction manager to manage transactions across multiple resource managers. A resource manager represents an EIS. Transactions managed by the transaction manager external to the resource manager, in this case the transaction manager in the application server, are called global or XA transactions. This contract also supports local transactions that are managed internally by a resource manager.

The security management contract provides authentication, authorization and secure communication between the J2EE server and the EIS.

Managed and Non-managed Environment
There are two types of client access scenarios: managed and non-managed.

In a managed environment, the application server takes over the management of the connection objects. When the client makes a call to the Connection Factory, it is routed to the Connection Manager. The Connection Manager requests the Managed Connection Factory to obtain a connection object.

In a non-managed environment, an application client directly uses the resource adapter to access the EIS.


JCA Interfaces
The Connector architecture includes the following interfaces:

ConnectionFactory: Repository of connection objects. This is implemented by the resource adapter.
ConnectionManager: Implemented by the application server to manage connections and transactions in a managed environment.
ManagedConnectionFactory: Implemented by the resource adapter and used to decide and return the connection object that is suitable to the client.
Connection: Implemented by the resource adapter, this interface is the object that allows access to the EIS.
ConnectionEventListener: Each connection instance is associated with this interface. This is used by the application server to get information from a connection instance and manage the connection pool.


To get a connection to the EIS, the client does a look up of the connection factory in the JNDI namespace. In a managed environment, the client invokes the getConnection method and the Connection Factory (CF) sends the connection request to the ConnectionManager (CM). The connection manager routes the request to the Managed Connection Factory (MCF). The MCF decides if the connection objects existing in the connection pool match the connection request from the client. If there is a match, the connection object is returned to the client. However, if there is no match, the connection manager creates the required connection object using the MCF. This new connection object is now a part of the connection pool. The MCF then returns the connection object to the client through the CF.

Each connection object is associated with a ConnectionEventListener interface. Any change in the connection status is passed to the application server through this interface.

The application client uses the connection to access the EIS. The connection is enlisted in the regular application server started transaction (in the case of local and XA transactions). Information exchange between the client and the EIS now takes place.

After the client closes the connection, the change in status is passed to the application server through the ConnectionEventListener interface. The connection object is then returned to the connection pool for reuse.

0 Comments:

Post a Comment

<< Home