Class TransactionRegistry
- java.lang.Object
- 
- org.apache.tomcat.dbcp.dbcp2.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. - Since:
- 2.0
 
- 
- 
Constructor SummaryConstructors Constructor Description TransactionRegistry(TransactionManager transactionManager)Provided for backwards compatibilityTransactionRegistry(TransactionManager transactionManager, TransactionSynchronizationRegistry transactionSynchronizationRegistry)Creates a TransactionRegistry for the specified transaction manager.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description TransactionContextgetActiveTransactionContext()Gets the active TransactionContext or null if not Transaction is active.XAResourcegetXAResource(java.sql.Connection connection)Gets the XAResource registered for the connection.voidregisterConnection(java.sql.Connection connection, XAResource xaResource)Registers the association between a Connection and a XAResource.voidunregisterConnection(java.sql.Connection connection)Unregisters a destroyed connection fromTransactionRegistry.
 
- 
- 
- 
Constructor Detail- 
TransactionRegistrypublic TransactionRegistry(TransactionManager transactionManager) Provided for backwards compatibility- Parameters:
- transactionManager- the transaction manager used to enlist connections
 
 - 
TransactionRegistrypublic TransactionRegistry(TransactionManager transactionManager, TransactionSynchronizationRegistry transactionSynchronizationRegistry) Creates a TransactionRegistry for the specified transaction manager.- Parameters:
- transactionManager- the transaction manager used to enlist connections.
- transactionSynchronizationRegistry- The optional TSR to register synchronizations with
- Since:
- 2.6.0
 
 
- 
 - 
Method Detail- 
getActiveTransactionContextpublic TransactionContext getActiveTransactionContext() throws java.sql.SQLException Gets the active TransactionContext or null if not Transaction is active.- Returns:
- The active TransactionContext or null if no Transaction is active.
- Throws:
- java.sql.SQLException- Thrown when an error occurs while fetching the transaction.
 
 - 
getXAResourcepublic 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- Thrown when the connection does not have a registered XAResource.
 
 - 
registerConnectionpublic void registerConnection(java.sql.Connection connection, 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 connection.
- xaResource- The XAResource which managed the connection within a transaction.
 
 - 
unregisterConnectionpublic void unregisterConnection(java.sql.Connection connection) Unregisters a destroyed connection fromTransactionRegistry.- Parameters:
- connection- A destroyed connection from- TransactionRegistry.
 
 
- 
 
-