U N C H A I N E D - M E L O D Y.

Thursday, February 02, 2006

Connection Management

One of the most beautiful things i've ever experienced. Hats off to the Sun guys...
An excerpt from J2EE ConnectorArchitecture Specification:

"The application server uses the deployment descriptor mechanism to configure the resource adapter in the operational environment.
The resource adapter provides connection and connection factory interfaces. A connection factory acts as a factory for EIS connections. For example, javax.sql.DataSource and java.
sql.Connection interfaces are JDBC-based interfaces for connectivity to a relational
database.
The CCI defines javax.resource.cci.ConnectionFactory and javax.resource.cci.Connection as interfaces for a connection factory and a connection respectively. The application component does a lookup of a connection factory in the JNDI name space. It uses the connection factory to get a connection to the underlying EIS. The connection factory instance delegates the connection creation request to the ConnectionManager instance.
The ConnectionManager enables the application server to provide different quality of services in the managed application scenario. These quality of services include transaction management, security, error logging and tracing, and connection pool management. The application server provides these services in its own implementation-specific way. The connector architecture does not specify how the application server implements these services.

The ConnectionManager instance, on receiving a connection creation request from the connection factory, does a lookup in the connection pool provided by the application server. If there is no connection in the pool that can satisfy the connection request, the application server uses the ManagedConnectionFactory interface (implemented by the resource adapter) to create a new physical connection to the underlying EIS. If the application server finds a matching
connection in the pool, then it uses the matching ManagedConnection instance to satisfy the connection request. If a new ManagedConnection instance is created, the application server adds the new ManagedConnection instance to the connection pool. The application server registers a ConnectionEventListener with the ManagedConnection instance. This listener enables application server to get event notifications related to the state of the ManagedConnection instance. The application server uses these notifications to manage connection pooling, manage transactions, cleanup connections, and handle any error conditions. The application server uses the ManagedConnection instance to get a connection instance that acts as an application-level handle to the underlying physical connection. An instance of type javax.resource.cci.Connection is an example of such a connection handle. An application component uses the connection handle to access EIS resources. The resource adapter implements the XAResource interface to provide support for transaction management. The resource adapter also implements the LocalTransaction interface so that the application server can manage transactions internal to a resource manager. The chapter on transaction management describes this transaction management contract between the application server (and its transaction manager) and the resource adapter (and its underlying resource manager)."

In short, just follow a specification and write java connectors to almost any EIS.

1 Comments:

Blogger Rishabh said...

Could not understand why spiManagedConnectionFactory Constuctor is called again while application server shutdown????????

getting nuts...

6:36 PM, February 07, 2006

 

Post a Comment

<< Home