org.jboss.resource.connectionmanager
Class TxConnectionManager

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.resource.connectionmanager.BaseConnectionManager2 (src) 
              extended byorg.jboss.resource.connectionmanager.TxConnectionManager
All Implemented Interfaces:
ConnectionCacheListener (src) , ConnectionListenerFactory (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class TxConnectionManager
extends BaseConnectionManager2 (src)

The LocalTxConnectionManager is a JBoss ConnectionManager implementation for jca adapters implementing LocalTransaction 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. 5. When an "entering object" notification is received from the CachedConnectionInterceptor, all the connections for the current object must be associated with a ManagedConnection. if there is a Transaction, the XAResource must be enlisted with it. Entry point: ConnectionCacheListener.reconnect(Collection conns) The Collection is of ConnectionRecord objects. written. 6. When a "leaving object" notification is received from the CachedConnectionInterceptor, all the managedConnections for the current object must have their XAResources delisted from the current Transaction, if any, and cleanup called on each ManagedConnection. Entry point: ConnectionCacheListener.disconnect(Collection conns). written. Created: Fri Sept 6 11:13:28 2002


Nested Class Summary
protected  class TxConnectionManager.TxConnectionEventListener (src)
           
 
Nested classes inherited from class org.jboss.resource.connectionmanager.BaseConnectionManager2 (src)
BaseConnectionManager2.BaseConnectionEventListener (src) , BaseConnectionManager2.ConnectionManagerProxy (src)
 
Field Summary
 
Fields inherited from class org.jboss.resource.connectionmanager.BaseConnectionManager2 (src)
jndiName, poolingStrategy, STOPPING_NOTIFICATION, trace
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
TxConnectionManager()
          Default managed LocalTxConnectionManager constructor for mbean instances.
TxConnectionManager(CachedConnectionManager (src)  ccm, ManagedConnectionPool (src)  poolingStrategy, TransactionManager (src)  tm)
          Creates a new TxConnectionManager instance.
 
Method Summary
 ConnectionListener (src) createConnectionListener(ManagedConnection (src)  mc, java.lang.Object context)
          Create a managed connection listener for the managed connection
 ConnectionListener (src) getManagedConnection(javax.security.auth.Subject subject, ConnectionRequestInfo (src)  cri)
          Describe getManagedConnection method here.
 java.lang.String getTransactionManager()
          Deprecated. use the ObjectName TransactionManagerService instead
 TransactionManager (src) getTransactionManagerInstance()
          Get the transaction manager
 ObjectName (src) getTransactionManagerService()
          mbean get-set pair for field transactionManagerService Get the value of transactionManagerService
 boolean isLocalTransactions()
          mbean get-set pair for field localTransactions Get the value of localTransactions
 boolean isTrackConnectionByTx()
          mbean get-set pair for field trackConnectionByTx Get the value of trackConnectionByTx
 boolean isTransactional()
          Determine whether is a transaction
protected  void managedConnectionDisconnected(ConnectionListener (src)  cl)
          For polymorphism.
protected  void managedConnectionReconnected(ConnectionListener (src)  cl)
          For polymorphism.
 void setLocalTransactions(boolean localTransactions)
          Set the value of localTransactions
 void setTrackConnectionByTx(boolean trackConnectionByTx)
          Set the value of trackConnectionByTx
 void setTransactionManager(java.lang.String tmName)
          Deprecated. use the ObjectName TransactionManagerService instead
 void setTransactionManagerInstance(TransactionManager (src)  tm)
           
 void setTransactionManagerService(ObjectName (src)  transactionManagerService)
          Set the value of transactionManagerService
protected  void startService()
          Sub-classes should override this method to provide custum 'start' logic.
protected  void stopService()
          Sub-classes should override this method to provide custum 'stop' logic.
 void transactionStarted(java.util.Collection crs)
           
 
Methods inherited from class org.jboss.resource.connectionmanager.BaseConnectionManager2 (src)
allocateConnection, disconnect, disconnectManagedConnection, getCachedConnectionManager, getCcm, getConnectionCount, getInstance, getJaasSecurityManagerService, getJndiName, getManagedConnection, getManagedConnectionFactory, getManagedConnectionPool, getNotificationInfo, getPoolingStrategy, getSecurityDomainJndiName, reconnect, reconnectManagedConnection, rethrowAsResourceException, returnManagedConnection, setCachedConnectionManager, setJaasSecurityManagerService, setJndiName, setManagedConnectionPool, setSecurityDomainJndiName, unregisterAssociation
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TxConnectionManager

public TxConnectionManager()
Default managed LocalTxConnectionManager constructor for mbean instances.


TxConnectionManager

public TxConnectionManager(CachedConnectionManager (src)  ccm,
                           ManagedConnectionPool (src)  poolingStrategy,
                           TransactionManager (src)  tm)
Creates a new TxConnectionManager instance. for TESTING ONLY!!! not a managed constructor!!

Parameters:
ccm - a CachedConnectionManager value
poolingStrategy - a ManagedConnectionPool value
tm - a TransactionManager value
Method Detail

getTransactionManagerService

public ObjectName (src)  getTransactionManagerService()
mbean get-set pair for field transactionManagerService Get the value of transactionManagerService

Returns:
value of transactionManagerService

setTransactionManagerService

public void setTransactionManagerService(ObjectName (src)  transactionManagerService)
Set the value of transactionManagerService

Parameters:
transactionManagerService - Value to assign to transactionManagerService

setTransactionManager

public void setTransactionManager(java.lang.String tmName)
Deprecated. use the ObjectName TransactionManagerService instead

The TransactionManager attribute contains the jndi name of the TransactionManager. This is normally java:/TransactionManager.


getTransactionManager

public java.lang.String getTransactionManager()
Deprecated. use the ObjectName TransactionManagerService instead

Describe getTransactionManager method here.

Returns:
an String value

getTransactionManagerInstance

public TransactionManager (src)  getTransactionManagerInstance()
Description copied from interface: ConnectionListenerFactory (src)
Get the transaction manager

Specified by:
getTransactionManagerInstance in interface ConnectionListenerFactory (src)
Overrides:
getTransactionManagerInstance in class BaseConnectionManager2 (src)

setTransactionManagerInstance

public void setTransactionManagerInstance(TransactionManager (src)  tm)

isTrackConnectionByTx

public boolean isTrackConnectionByTx()
mbean get-set pair for field trackConnectionByTx Get the value of trackConnectionByTx

Returns:
value of trackConnectionByTx

setTrackConnectionByTx

public void setTrackConnectionByTx(boolean trackConnectionByTx)
Set the value of trackConnectionByTx

Parameters:
trackConnectionByTx - Value to assign to trackConnectionByTx

isLocalTransactions

public boolean isLocalTransactions()
mbean get-set pair for field localTransactions Get the value of localTransactions

Returns:
value of localTransactions

setLocalTransactions

public void setLocalTransactions(boolean localTransactions)
Set the value of localTransactions

Parameters:
localTransactions - Value to assign to localTransactions

startService

protected void startService()
                     throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'start' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
startService in class BaseConnectionManager2 (src)
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'stop' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
stopService in class BaseConnectionManager2 (src)
Throws:
java.lang.Exception

getManagedConnection

public ConnectionListener (src)  getManagedConnection(javax.security.auth.Subject subject,
                                               ConnectionRequestInfo (src)  cri)
                                        throws ResourceException (src) 
Description copied from class: BaseConnectionManager2 (src)
Describe getManagedConnection method here. Public for use in testing pooling functionality by itself. called by both allocateConnection and reconnect.

Overrides:
getManagedConnection in class BaseConnectionManager2 (src)
Parameters:
subject - a Subject value
cri - a ConnectionRequestInfo value
Returns:
a ManagedConnection value
Throws:
ResourceException (src) - if an error occurs

transactionStarted

public void transactionStarted(java.util.Collection crs)
                        throws SystemException (src) 
Specified by:
transactionStarted in interface ConnectionCacheListener (src)
Overrides:
transactionStarted in class BaseConnectionManager2 (src)
Throws:
SystemException (src)

managedConnectionReconnected

protected void managedConnectionReconnected(ConnectionListener (src)  cl)
                                     throws ResourceException (src) 
Description copied from class: BaseConnectionManager2 (src)
For polymorphism.

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

Overrides:
managedConnectionReconnected in class BaseConnectionManager2 (src)
Throws:
ResourceException (src)

managedConnectionDisconnected

protected void managedConnectionDisconnected(ConnectionListener (src)  cl)
                                      throws ResourceException (src) 
Description copied from class: BaseConnectionManager2 (src)
For polymorphism.

Do not invoke directly use disconnectManagedConnection which does the relevent exception handling

Overrides:
managedConnectionDisconnected in class BaseConnectionManager2 (src)
Throws:
ResourceException (src)

createConnectionListener

public ConnectionListener (src)  createConnectionListener(ManagedConnection (src)  mc,
                                                   java.lang.Object context)
                                            throws ResourceException (src) 
Description copied from interface: ConnectionListenerFactory (src)
Create a managed connection listener for the managed connection

Parameters:
mc - the managed connection
context - a context object used by the pool
Returns:
a new connection event listener
Throws:
ResourceException (src) - for any error

isTransactional

public boolean isTransactional()
Description copied from interface: ConnectionListenerFactory (src)
Determine whether is a transaction

Specified by:
isTransactional in interface ConnectionListenerFactory (src)
Overrides:
isTransactional in class BaseConnectionManager2 (src)