org.apache.commons.dbcp2.managed

Class TransactionRegistry



  • public class TransactionRegistry
    extends 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 transaction, allowing for the maximal rescue of DBCP.

    Since:
    2.0
    • 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

      • registerConnection

        public void registerConnection(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.
      • getXAResource

        public XAResource getXAResource(Connection connection)
                                 throws SQLException
        Gets the XAResource registered for the connection.
        Parameters:
        connection - the connection
        Returns:
        The XAResource registered for the connection; never null.
        Throws:
        SQLException - Thrown when the connection does not have a registered XAResource.

Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.