org.jboss.jca.core.connectionmanager.tx

## Class TxConnectionManagerImpl

- java.lang.Object
- - org.jboss.jca.core.connectionmanager.AbstractConnectionManager
  - - org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl

- All Implemented Interfaces:
    java.io.Serializable, javax.resource.spi.ConnectionManager, javax.resource.spi.LazyAssociatableConnectionManager, javax.resource.spi.LazyEnlistableConnectionManager, org.jboss.jca.core.api.connectionmanager.listener.ConnectionCacheListener, TxConnectionManager, org.jboss.jca.core.spi.graceful.GracefulShutdown, org.jboss.jca.core.spi.transaction.TransactionTimeoutConfiguration

      public class TxConnectionManagerImpl
      extends AbstractConnectionManager
      implements TxConnectionManager

  The TxConnectionManager is a JBoss ConnectionManager implementation for JCA adapters implementing LocalTransaction and XAResource support. It implements a ConnectionEventListener that implements XAResource to manage transactions through the Transaction Manager. To assure that all work in a local transaction occurs over the same ManagedConnection, it includes a xid to ManagedConnection map. When a Connection is requested or a transaction started with a connection handle in use, it checks to see if a ManagedConnection already exists enrolled in the global transaction and uses it if found. Otherwise a free ManagedConnection has its LocalTransaction started and is used. From the BaseConnectionManager2, it includes functionality to obtain managed connections from a ManagedConnectionPool mbean, find the Subject from a SubjectSecurityDomain, and interact with the CachedConnectionManager for connections held over transaction and method boundaries. Important mbean references are to a ManagedConnectionPool supplier (typically a JBossManagedConnectionPool), and a RARDeployment representing the ManagedConnectionFactory. This connection manager has to perform the following operations: 1. When an application component requests a new ConnectionHandle, it must find a ManagedConnection, and make sure a ConnectionEventListener is registered. It must inform the CachedConnectionManager that a connection handle has been given out. It needs to count the number of handles for each ManagedConnection. If there is a current transaction, it must enlist the ManagedConnection's LocalTransaction in the transaction using the ConnectionEventListeners XAResource XAResource implementation. Entry point: ConnectionManager.allocateConnection. written. 2. When a ConnectionClosed event is received from the ConnectionEventListener, it must reduce the handle count. If the handle count is zero, the XAResource should be delisted from the Transaction, if any. The CachedConnectionManager must be notified that the connection is closed. Entry point: ConnectionEventListener.ConnectionClosed. written 3. When a transaction begun notification is received from the UserTransaction (via the CachedConnectionManager, all managedConnections associated with the current object must be enlisted in the transaction. Entry point: (from CachedConnectionManager) ConnectionCacheListener.transactionStarted(Transaction, Collection). The collection is of ConnectionRecord objects. written.
  Author:
    David Jencks, Adrian Brock, Weston Price, Jesper Pedersen
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.jboss.jca.core.connectionmanager.AbstractConnectionManager

      `connectable, enlistment, enlistmentTrace, tracking`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TxConnectionManagerImpl(org.jboss.jca.core.spi.transaction.TransactionIntegration txIntegration, boolean localTransactions)` Constructor

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ConnectionListener` | `createConnectionListener(javax.resource.spi.ManagedConnection mc, ManagedConnectionPool mcp)` Create a managed connection listener for the managed connection.
    `java.lang.Boolean` | `getIsSameRMOverride()` Get the IsSameRMOverride value
    `protected CoreLogger` | `getLogger()` Get the logger.
    `ConnectionListener` | `getManagedConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)` Public for use in testing pooling functionality by itself.
    `boolean` | `getPadXid()` Get PadXis status
    `long` | `getTimeLeftBeforeTransactionTimeout(boolean errorRollback)` Gets time left.
    `org.jboss.jca.core.spi.transaction.TransactionIntegration` | `getTransactionIntegration()` Get the transaction integration instance
    `int` | `getTransactionTimeout()` Get the transaction timeout.
    `boolean` | `getWrapXAResource()` Returns true if wrap xa resource.
    `int` | `getXAResourceTimeout()` Gets XA resource transaction time out.
    `boolean` | `isAllowMarkedForRollback()` Is allow marked for rollback enabled
    `boolean` | `isInterleaving()` Gets interleaving flag.
    `boolean` | `isLocalTransactions()` Returns local tx or not.
    `boolean` | `isTransactional()` Determine whether there connection is a transactional.
    `void` | `lazyEnlist(javax.resource.spi.ManagedConnection mc)`
    `protected void` | `managedConnectionReconnected(ConnectionListener cl)` For polymorphism.
    `static void` | `rethrowAsSystemException(java.lang.String context, javax.transaction.Transaction tx, java.lang.Throwable t)` RethrowAsSystemException.
    `void` | `setInterleaving(boolean value)` Sets interleaving flag.
    `void` | `setIsSameRMOverride(java.lang.Boolean v)` Set the IsSameRMOverride value.
    `void` | `setPadXid(boolean v)` Set if the Xid should be padded
    `void` | `setWrapXAResource(boolean v)` Set if the XAResource should be wrapped
    `void` | `setXAResourceTimeout(int timeout)` Sets XA resource transaction timeout.
    `void` | `transactionStarted(java.util.Collection<ConnectionRecord> crs)` Notification of transaction started

    - ### Methods inherited from class org.jboss.jca.core.connectionmanager.AbstractConnectionManager

      `allocateConnection, associateConnection, associateManagedConnection, cancelShutdown, disconnectManagedConnection, dissociateManagedConnection, getAllocationRetry, getAllocationRetryWaitMillis, getCachedConnectionManager, getDelay, getEnlistmentTrace, getFlushStrategy, getJndiName, getManagedConnection, getManagedConnectionFactory, getPool, getSecurityDomain, getSubjectFactory, getTracking, inactiveConnectionClosed, isConnectable, isEnlistment, isSharable, isShutdown, managedConnectionDisconnected, prepareShutdown, prepareShutdown, prepareShutdown, prepareShutdown, reconnectManagedConnection, returnManagedConnection, setAllocationRetry, setAllocationRetryWaitMillis, setCachedConnectionManager, setConnectable, setEnlistment, setEnlistmentTrace, setFlushStrategy, setJndiName, setPool, setSecurityDomain, setSharable, setSubjectFactory, setTracking, shutdown, unregisterAssociation`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.jboss.jca.core.connectionmanager.ConnectionManager

      `getAllocationRetry, getAllocationRetryWaitMillis, getCachedConnectionManager, getJndiName, getPool, getSecurityDomain, getSubjectFactory, isEnlistment, isSharable, setJndiName, unregisterAssociation`

    - ### Methods inherited from interface org.jboss.jca.core.api.connectionmanager.ConnectionManager

      `associateManagedConnection, dissociateManagedConnection, returnManagedConnection`

    - ### Methods inherited from interface javax.resource.spi.ConnectionManager

      `allocateConnection`

    - ### Methods inherited from interface javax.resource.spi.LazyAssociatableConnectionManager

      `associateConnection, inactiveConnectionClosed`

    - ### Methods inherited from interface org.jboss.jca.core.spi.graceful.GracefulShutdown

      `cancelShutdown, getDelay, isShutdown, prepareShutdown, prepareShutdown, prepareShutdown, prepareShutdown, shutdown`

- - ### Constructor Detail

    - #### TxConnectionManagerImpl

          public TxConnectionManagerImpl(org.jboss.jca.core.spi.transaction.TransactionIntegration txIntegration,
                                         boolean localTransactions)

      Constructor
      Parameters:
        `txIntegration` - The transaction integration layer
        `localTransactions` - Is local transactions enabled

  - ### Method Detail

    - #### getLogger

          protected CoreLogger getLogger()

      Get the logger.
      Specified by:
        `getLogger` in class `AbstractConnectionManager`
      Returns:
        The value

    - #### getTransactionIntegration

          public org.jboss.jca.core.spi.transaction.TransactionIntegration getTransactionIntegration()

      Get the transaction integration instance
      Specified by:
        `getTransactionIntegration` in class `AbstractConnectionManager`
      Returns:
        The transaction integration

    - #### isInterleaving

          public boolean isInterleaving()

      Gets interleaving flag.
      Specified by:
        `isInterleaving` in interface `TxConnectionManager`
      Returns:
        interleaving flag

    - #### setInterleaving

          public void setInterleaving(boolean value)

      Sets interleaving flag.
      Parameters:
        `value` - interleaving

    - #### isLocalTransactions

          public boolean isLocalTransactions()

      Returns local tx or not.
      Specified by:
        `isLocalTransactions` in interface `TxConnectionManager`
      Returns:
        local tx or not

    - #### getXAResourceTimeout

          public int getXAResourceTimeout()

      Gets XA resource transaction time out.
      Specified by:
        `getXAResourceTimeout` in interface `TxConnectionManager`
      Returns:
        xa resource transaction timeout

    - #### setXAResourceTimeout

          public void setXAResourceTimeout(int timeout)

      Sets XA resource transaction timeout.
      Parameters:
        `timeout` - xa resource transaction timeout

    - #### getIsSameRMOverride

          public java.lang.Boolean getIsSameRMOverride()

      Get the IsSameRMOverride value
      Specified by:
        `getIsSameRMOverride` in interface `TxConnectionManager`
      Returns:
        The value

    - #### setIsSameRMOverride

          public void setIsSameRMOverride(java.lang.Boolean v)

      Set the IsSameRMOverride value.
      Parameters:
        `v` - The value

    - #### getWrapXAResource

          public boolean getWrapXAResource()

      Returns true if wrap xa resource.
      Specified by:
        `getWrapXAResource` in interface `TxConnectionManager`
      Returns:
        true if wrap xa resource

    - #### setWrapXAResource

          public void setWrapXAResource(boolean v)

      Set if the XAResource should be wrapped
      Parameters:
        `v` - The value

    - #### getPadXid

          public boolean getPadXid()

      Get PadXis status
      Specified by:
        `getPadXid` in interface `TxConnectionManager`
      Returns:
        The value

    - #### setPadXid

          public void setPadXid(boolean v)

      Set if the Xid should be padded
      Parameters:
        `v` - The value

    - #### isAllowMarkedForRollback

          public boolean isAllowMarkedForRollback()

      Is allow marked for rollback enabled
      Specified by:
        `isAllowMarkedForRollback` in interface `TxConnectionManager`
      Returns:
        `True` if set, otherwise `false`

    - #### getTimeLeftBeforeTransactionTimeout

          public long getTimeLeftBeforeTransactionTimeout(boolean errorRollback)
                                                   throws javax.transaction.RollbackException

      Gets time left.
      Specified by:
        `getTimeLeftBeforeTransactionTimeout` in interface `org.jboss.jca.core.spi.transaction.TransactionTimeoutConfiguration`
      Parameters:
        `errorRollback` - error rollback
      Returns:
        time left in ms
      Throws:
        `javax.transaction.RollbackException` - if exception

    - #### getManagedConnection

          public ConnectionListener getManagedConnection(javax.security.auth.Subject subject,
                                                         javax.resource.spi.ConnectionRequestInfo cri)
                                                  throws javax.resource.ResourceException

      Public for use in testing pooling functionality by itself. called by both allocateConnection and reconnect.
      Overrides:
        `getManagedConnection` in class `AbstractConnectionManager`
      Parameters:
        `subject` - a `Subject` value
        `cri` - a `ConnectionRequestInfo` value
      Returns:
        a `ManagedConnection` value
      Throws:
        `javax.resource.ResourceException` - if an error occurs

    - #### transactionStarted

          public void transactionStarted(java.util.Collection<ConnectionRecord> crs)
                                  throws javax.transaction.SystemException

      Notification of transaction started
      Specified by:
        `transactionStarted` in class `AbstractConnectionManager`
      Parameters:
        `crs` - the connections
      Throws:
        `javax.transaction.SystemException` - for any error

    - #### managedConnectionReconnected

          protected void managedConnectionReconnected(ConnectionListener cl)
                                               throws javax.resource.ResourceException

      For polymorphism.

      Do not invoke directly, use reconnectManagedConnection which does the relevent exception handling

      Overrides:
        `managedConnectionReconnected` in class `AbstractConnectionManager`
      Parameters:
        `cl` - connection listener
      Throws:
        `javax.resource.ResourceException` - for exception

    - #### createConnectionListener

          public ConnectionListener createConnectionListener(javax.resource.spi.ManagedConnection mc,
                                                             ManagedConnectionPool mcp)
                                                      throws javax.resource.ResourceException

      Create a managed connection listener for the managed connection.
      Parameters:
        `mc` - the managed connection
        `mcp` - the managed connection pool
      Returns:
        a new connection event listener
      Throws:
        `javax.resource.ResourceException` - for any error

    - #### isTransactional

          public boolean isTransactional()

      Determine whether there connection is a transactional.
      Specified by:
        `isTransactional` in class `AbstractConnectionManager`
      Returns:
        whether it is a transactional or not

    - #### getTransactionTimeout

          public int getTransactionTimeout()
                                    throws javax.transaction.SystemException

      Get the transaction timeout.
      Specified by:
        `getTransactionTimeout` in interface `org.jboss.jca.core.spi.transaction.TransactionTimeoutConfiguration`
      Returns:
        The timeout in seconds associated with this thread
      Throws:
        `javax.transaction.SystemException` - For any error

    - #### lazyEnlist

          public void lazyEnlist(javax.resource.spi.ManagedConnection mc)
                          throws javax.resource.ResourceException

      Specified by:
        `lazyEnlist` in interface `javax.resource.spi.LazyEnlistableConnectionManager`
      Overrides:
        `lazyEnlist` in class `AbstractConnectionManager`
      Throws:
        `javax.resource.ResourceException`

    - #### rethrowAsSystemException

          public static void rethrowAsSystemException(java.lang.String context,
                                                      javax.transaction.Transaction tx,
                                                      java.lang.Throwable t)
                                               throws javax.transaction.SystemException

      RethrowAsSystemException.
      Parameters:
        `context` - context
        `tx` - transaction
        `t` - throwable
      Throws:
        `javax.transaction.SystemException` - system exception

Copyright © 2014 IronJacamar (http://www.ironjacamar.org)