www.ironjacamar.orgCommunity Documentation

Chapter 8. Connection manager

Table of Contents

8.1. Overview
8.2. Public API
8.3. Private API
8.4. Implementation
8.4.1. AbstractConnectionManager
8.4.2. NoTxConnectionManagerImpl
8.4.3. TxConnectionManagerImpl
8.4.4. AbstractConnectionListener
8.4.5. NoTxConnectionListener
8.4.6. TxConnectionListener

The connection manager defines the interface for resource adapters to allocate connections, which are associated with the physical connections to the target Enterprise Information System, such as a database.

It is up to the connection manager to use the pool, and enlist the connection listeners in the transactions, if supported.

The connection manager architecture

The public API defines the API that programs external to the IronJacamar project can use to configure, and use the connection manager.

The ConnectionManager interface allows to associate and dissociate a managed connection with a connection.

The ConnectionListener interface provides with IronJacamar contract for javax.resource.spi.ConnectionEventListener.

The package for the public API is org.jboss.jca.core.api.connectionmanager.

The private API defines the API that can be used internally IronJacamar to control the connection manager. The API extends the public API where it makes sense in order to provide a more uniform interface to the implementation.

The ConnectionManagerFactory class can create a ConnectionManager instance.

The ConnectionManager interface defines the internal API of the connection manager used by IronJacamar.

The NoTxConnectionManager interface defines the internal API of a non-transactional connection manager.

The TxConnectionManager interface defines the internal API of a transactional connection manager.

The ConnectionListener interface defines the internal API of a connection listener, which is associated with a managed connection.

The package for the private API is org.jboss.jca.core.connectionmanager.

The implementation of the connection manager is split in two classes, with a shared base class for common functionality.

TxConnectionListener is the listener for LocalTransaction and XATransaction scenarios.

used() updates the last used time, and resets the timeout value for the underlying XAResource if in XATransaction mode.

enlist() enlists the XAResource instances in the transaction through TransactionSynchronization including resources picked up by the CachedConnectionManager.

delist() delists the XAResource from the transaction in interleaved scenarios.

dissociate() dissociates the ConnectionListener with the transaction.

connectionClosed(ConnectionEvent) dissociates a connection handle through wasFreed(Object) and returns the ManagedConnection in interleaved scenarios.

connectionErrorOccurred(ConnectionEvent) clears any TransactionSynchronization object such that the ManagedConnection can be returned for destruction.

tidyup() will rollback any left over LocalTransaction instance.

isManagedConnectionFree() checks if there is exists a TransactionSynchronization object in track by transaction scenarios, since the ManagedConnection can't be returned in that case.

wasFreed(Object) dissociates a connection handle from the ConnectionListener, or resets the track by transaction flag if null such that the ManagedConnection can be returned.

The TransactionSynchronization class takes care of enlisting the XAResource in the transaction, in track by transaction scenarios. This is done in its enlist() and its result can be verified in checkEnlisted(). The beforeCompletion() method delists the XAResource from the transaction. The afterCompletion(int) method returns the ManagedConnection to the pool.