org.apache.commons.dbcp.managed
Class TransactionRegistry

java.lang.Object
  extended by org.apache.commons.dbcp.managed.TransactionRegistry

public class TransactionRegistry
extends java.lang.Object

TransactionRegistry tracks Connections and XAResources in a transacted environment for a single XAConnectionFactory.

The TransactionRegistry hides the details of transaction processing from the existing DBCP pooling code, and gives the ManagedConnection a way to enlist connections in a tranaction, allowing for the maximal resue of DBCP.

Version:
$Revision$
Author:
Dain Sundstrom

Constructor Summary
TransactionRegistry(TransactionManager transactionManager)
          Creates a TransactionRegistry for the specified transaction manager.
 
Method Summary
 TransactionContext getActiveTransactionContext()
          Gets the active TransactionContext or null if not Transaction is active.
 javax.transaction.xa.XAResource getXAResource(java.sql.Connection connection)
          Gets the XAResource registered for the connection.
 void registerConnection(java.sql.Connection connection, javax.transaction.xa.XAResource xaResource)
          Registers the association between a Connection and a XAResource.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionRegistry

public TransactionRegistry(TransactionManager transactionManager)
Creates a TransactionRegistry for the specified transaction manager.

Parameters:
transactionManager - the transaction manager used to enlist connections
Method Detail

getActiveTransactionContext

public TransactionContext getActiveTransactionContext()
                                               throws java.sql.SQLException
Gets the active TransactionContext or null if not Transaction is active.

Returns:
the active TransactionContext or null if not Transaction is active
Throws:
java.sql.SQLException - if an error occurs while fetching the transaction

getXAResource

public javax.transaction.xa.XAResource getXAResource(java.sql.Connection connection)
                                              throws java.sql.SQLException
Gets the XAResource registered for the connection.

Parameters:
connection - the connection
Returns:
the XAResource registered for the connection; never null
Throws:
java.sql.SQLException - if the connection does not have a registered XAResource

registerConnection

public void registerConnection(java.sql.Connection connection,
                               javax.transaction.xa.XAResource xaResource)
Registers the association between a Connection and a XAResource. When a conection is enlisted in a transaction, it is acutally the XAResource that is given to the transaction manager.

Parameters:
connection - the JDBC connection
xaResource - the XAResource which managed the connection within a transaction


Copyright © 2001-2004 Apache Software Foundation. Documenation generated December 11 2009.