Package org.apache.commons.dbcp2.managed
Class TransactionRegistry
java.lang.Object
org.apache.commons.dbcp2.managed.TransactionRegistry
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 transaction, allowing for the maximal rescue of DBCP.
- Since:
- 2.0
- Version:
- $Id: TransactionRegistry.java 1660791 2015-02-19 04:13:10Z psteitz $
- Author:
- Dain Sundstrom
-
Constructor Summary
ConstructorsConstructorDescriptionTransactionRegistry
(javax.transaction.TransactionManager transactionManager) Creates a TransactionRegistry for the specified transaction manager. -
Method Summary
Modifier and TypeMethodDescriptionGets the active TransactionContext or null if not Transaction is active.getXAResource
(Connection connection) Gets the XAResource registered for the connection.void
registerConnection
(Connection connection, XAResource xaResource) Registers the association between a Connection and a XAResource.void
unregisterConnection
(Connection connection) Unregisters a destroyed connection fromTransactionRegistry
-
Constructor Details
-
TransactionRegistry
public TransactionRegistry(javax.transaction.TransactionManager transactionManager) Creates a TransactionRegistry for the specified transaction manager.- Parameters:
transactionManager
- the transaction manager used to enlist connections
-
-
Method Details
-
registerConnection
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
Gets the XAResource registered for the connection.- Parameters:
connection
- the connection- Returns:
- the XAResource registered for the connection; never null
- Throws:
SQLException
- if the connection does not have a registered XAResource
-
getActiveTransactionContext
Gets the active TransactionContext or null if not Transaction is active.- Returns:
- the active TransactionContext or null if no Transaction is active
- Throws:
SQLException
- if an error occurs while fetching the transaction
-
unregisterConnection
Unregisters a destroyed connection fromTransactionRegistry
- Parameters:
connection
-
-