Package org.apache.commons.dbcp.managed
Class TransactionRegistry
- java.lang.Object
-
- org.apache.commons.dbcp.managed.TransactionRegistry
-
public class TransactionRegistry extends java.lang.ObjectTransactionRegistry 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 transaction, allowing for the maximal rescue of DBCP.- Version:
- $Revision$
- Author:
- Dain Sundstrom
-
-
Constructor Summary
Constructors Constructor Description TransactionRegistry(javax.transaction.TransactionManager transactionManager)Creates a TransactionRegistry for the specified transaction manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransactionContextgetActiveTransactionContext()Gets the active TransactionContext or null if not Transaction is active.javax.transaction.xa.XAResourcegetXAResource(java.sql.Connection connection)Gets the XAResource registered for the connection.voidregisterConnection(java.sql.Connection connection, javax.transaction.xa.XAResource xaResource)Registers the association between a Connection and a XAResource.voidunregisterConnection(java.sql.Connection connection)Unregisters a destroyed connection fromTransactionRegistry
-
-
-
Method Detail
-
registerConnection
public void registerConnection(java.sql.Connection connection, javax.transaction.xa.XAResource xaResource)Registers the association between a Connection and a XAResource. When a connection is enlisted in a transaction, it is actually the XAResource that is given to the transaction manager.- Parameters:
connection- the JDBC connectionxaResource- the XAResource which managed the connection within a transaction
-
getXAResource
public javax.transaction.xa.XAResource getXAResource(java.sql.Connection connection) throws java.sql.SQLExceptionGets 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
-
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
-
unregisterConnection
public void unregisterConnection(java.sql.Connection connection)
Unregisters a destroyed connection fromTransactionRegistry- Parameters:
connection-
-
-