org.jboss.resource.connectionmanager
Class BaseConnectionManager2

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.resource.connectionmanager.BaseConnectionManager2
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, BaseConnectionManager2MBean, ConnectionCacheListener, ConnectionListenerFactory, org.jboss.system.Service, org.jboss.system.ServiceMBean, org.jboss.tm.TransactionTimeoutConfiguration
Direct Known Subclasses:
NoTxConnectionManager, TxConnectionManager

public abstract class BaseConnectionManager2
extends org.jboss.system.ServiceMBeanSupport
implements BaseConnectionManager2MBean, ConnectionCacheListener, ConnectionListenerFactory, org.jboss.tm.TransactionTimeoutConfiguration

The BaseConnectionManager2 is an abstract base class for JBoss ConnectionManager implementations. 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.

Version:
$Revision: 1.47.4.11 $
Author:
David Jencks, Erwin Guib, Adrian Brock

Nested Class Summary
protected  class BaseConnectionManager2.BaseConnectionEventListener
           
static class BaseConnectionManager2.ConnectionManagerProxy
           
 
Field Summary
protected  CachedConnectionManager ccm
           
protected  javax.management.ObjectName ccmName
           
protected  javax.management.ObjectName jaasSecurityManagerService
           
protected  String jndiName
           
protected  javax.management.ObjectName managedConnectionPoolName
           
protected  ManagedConnectionPool poolingStrategy
           
protected  org.jboss.security.SubjectSecurityManager securityDomain
           
protected  String securityDomainJndiName
           
static String STOPPING_NOTIFICATION
           
protected  boolean trace
           
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.resource.connectionmanager.BaseConnectionManager2MBean
OBJECT_NAME
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
BaseConnectionManager2()
          Default BaseConnectionManager2 managed constructor for use by subclass mbeans.
BaseConnectionManager2(CachedConnectionManager ccm, ManagedConnectionPool poolingStrategy)
          Creates a new BaseConnectionManager2 instance.
 
Method Summary
 Object allocateConnection(javax.resource.spi.ManagedConnectionFactory mcf, javax.resource.spi.ConnectionRequestInfo cri)
           
 void disconnect(Collection crs, Set unsharableResources)
          Notification to disconnect connections
protected  void disconnectManagedConnection(ConnectionListener cl)
          Invoked when a managed connection is no longer associated
 javax.management.ObjectName getCachedConnectionManager()
          Describe getCachedConnectionManager method here.
protected  CachedConnectionManager getCcm()
           
 int getConnectionCount()
           
 BaseConnectionManager2 getInstance()
          Describe getInstance method here.
 javax.management.ObjectName getJaasSecurityManagerService()
          Get the JaasSecurityManagerService value.
 String getJndiName()
          The JndiName attribute holds the jndi name the ConnectionFactory will be bound under in jndi.
 ConnectionListener getManagedConnection(Subject subject, javax.resource.spi.ConnectionRequestInfo cri)
          Public for use in testing pooling functionality by itself.
protected  ConnectionListener getManagedConnection(Transaction transaction, Subject subject, javax.resource.spi.ConnectionRequestInfo cri)
          Get the managed connection from the pool
 javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()
          ManagedConnectionFactory is an internal attribute that holds the ManagedConnectionFactory instance managed by this ConnectionManager.
 javax.management.ObjectName getManagedConnectionPool()
          The ManagedConnectionPool holds the ObjectName of the mbean representing the pool for this connection manager.
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
           
 ManagedConnectionPool getPoolingStrategy()
          For testing
 String getSecurityDomainJndiName()
          Get the SecurityDomainJndiName value.
 long getTimeLeftBeforeTransactionTimeout(boolean errorRollback)
           
 TransactionManager getTransactionManagerInstance()
          Get the transaction manager
 int getTransactionTimeout()
           
 boolean isTransactional()
          Determine whether is a transaction
protected  void managedConnectionDisconnected(ConnectionListener cl)
          For polymorphism.
protected  void managedConnectionReconnected(ConnectionListener cl)
          For polymorphism.
 void reconnect(Collection conns, Set unsharableResources)
          Notification to reconnect connections
protected  void reconnectManagedConnection(ConnectionListener cl)
          Invoked to reassociate a managed connection
protected static void rethrowAsResourceException(String message, Throwable t)
          Deprecated. use JBossResourceException.rethrowAsResourceException
 void returnManagedConnection(ConnectionListener cl, boolean kill)
           
 void setCachedConnectionManager(javax.management.ObjectName ccmName)
          The CachecConnectionManager holds the ObjectName of the CachedConnectionManager mbean used by this ConnectionManager.
 void setJaasSecurityManagerService(javax.management.ObjectName jaasSecurityManagerService)
          Set the JaasSecurityManagerService value.
 void setJndiName(String jndiName)
          Set the JndiName value.
 void setManagedConnectionPool(javax.management.ObjectName newManagedConnectionPool)
          Set the ManagedConnectionPool value.
 void setSecurityDomainJndiName(String securityDomainJndiName)
          The SecurityDomainJndiName holds the jndi name of the security domain configured for the ManagedConnectionFactory this ConnectionManager manages.
protected  void startService()
           
protected  void stopService()
           
 void transactionStarted(Collection conns)
          Notification of transaction started
protected  void unregisterAssociation(ConnectionListener cl, Object c)
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, createService, destroy, destroyService, getDeploymentInfo, 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
addNotificationListener, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 
Methods inherited from interface org.jboss.resource.connectionmanager.ConnectionListenerFactory
createConnectionListener
 

Field Detail

STOPPING_NOTIFICATION

public static final String STOPPING_NOTIFICATION
See Also:
Constant Field Values

managedConnectionPoolName

protected javax.management.ObjectName managedConnectionPoolName

poolingStrategy

protected ManagedConnectionPool poolingStrategy

jndiName

protected String jndiName

securityDomainJndiName

protected String securityDomainJndiName

securityDomain

protected org.jboss.security.SubjectSecurityManager securityDomain

jaasSecurityManagerService

protected javax.management.ObjectName jaasSecurityManagerService

ccmName

protected javax.management.ObjectName ccmName

ccm

protected CachedConnectionManager ccm

trace

protected boolean trace
Constructor Detail

BaseConnectionManager2

public BaseConnectionManager2()
Default BaseConnectionManager2 managed constructor for use by subclass mbeans.


BaseConnectionManager2

public BaseConnectionManager2(CachedConnectionManager ccm,
                              ManagedConnectionPool poolingStrategy)
Creates a new BaseConnectionManager2 instance. for TESTING ONLY! not a managed operation.

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

rethrowAsResourceException

protected static void rethrowAsResourceException(String message,
                                                 Throwable t)
                                          throws javax.resource.ResourceException
Deprecated. use JBossResourceException.rethrowAsResourceException

Rethrow a throwable as resource exception

Throws:
javax.resource.ResourceException

getPoolingStrategy

public ManagedConnectionPool getPoolingStrategy()
For testing


getJndiName

public String getJndiName()
Description copied from interface: BaseConnectionManager2MBean
The JndiName attribute holds the jndi name the ConnectionFactory will be bound under in jndi. Note that an entry of the form DefaultDS2 will be bound to java:/DefaultDS2.

Specified by:
getJndiName in interface BaseConnectionManager2MBean
Returns:
the JndiName value.

setJndiName

public void setJndiName(String jndiName)
Description copied from interface: BaseConnectionManager2MBean
Set the JndiName value.

Specified by:
setJndiName in interface BaseConnectionManager2MBean
Parameters:
jndiName - The JndiName value.

getManagedConnectionPool

public javax.management.ObjectName getManagedConnectionPool()
Description copied from interface: BaseConnectionManager2MBean
The ManagedConnectionPool holds the ObjectName of the mbean representing the pool for this connection manager. Normally it will be an embedded mbean in a depends tag rather than an ObjectName reference to the mbean.

Specified by:
getManagedConnectionPool in interface BaseConnectionManager2MBean
Returns:
the ManagedConnectionPool value.

setManagedConnectionPool

public void setManagedConnectionPool(javax.management.ObjectName newManagedConnectionPool)
Description copied from interface: BaseConnectionManager2MBean
Set the ManagedConnectionPool value.

Specified by:
setManagedConnectionPool in interface BaseConnectionManager2MBean
Parameters:
newManagedConnectionPool - The new ManagedConnectionPool value.

setCachedConnectionManager

public void setCachedConnectionManager(javax.management.ObjectName ccmName)
Description copied from interface: BaseConnectionManager2MBean
The CachecConnectionManager holds the ObjectName of the CachedConnectionManager mbean used by this ConnectionManager. Normally this will be a depends tag with the ObjectName of the unique CachedConnectionManager for the server.

Specified by:
setCachedConnectionManager in interface BaseConnectionManager2MBean
Parameters:
ccmName - an ObjectName value

getCachedConnectionManager

public javax.management.ObjectName getCachedConnectionManager()
Description copied from interface: BaseConnectionManager2MBean
Describe getCachedConnectionManager method here.

Specified by:
getCachedConnectionManager in interface BaseConnectionManager2MBean
Returns:
an ObjectName value

setSecurityDomainJndiName

public void setSecurityDomainJndiName(String securityDomainJndiName)
Description copied from interface: BaseConnectionManager2MBean
The SecurityDomainJndiName holds the jndi name of the security domain configured for the ManagedConnectionFactory this ConnectionManager manages. It is normally of the form java:/jaas/firebirdRealm, where firebirdRealm is the name found in auth.conf or equivalent file.

Specified by:
setSecurityDomainJndiName in interface BaseConnectionManager2MBean
Parameters:
securityDomainJndiName - an String value

getSecurityDomainJndiName

public String getSecurityDomainJndiName()
Description copied from interface: BaseConnectionManager2MBean
Get the SecurityDomainJndiName value.

Specified by:
getSecurityDomainJndiName in interface BaseConnectionManager2MBean
Returns:
the SecurityDomainJndiName value.

getJaasSecurityManagerService

public javax.management.ObjectName getJaasSecurityManagerService()
Description copied from interface: BaseConnectionManager2MBean
Get the JaasSecurityManagerService value.

Specified by:
getJaasSecurityManagerService in interface BaseConnectionManager2MBean
Returns:
the JaasSecurityManagerService value.

setJaasSecurityManagerService

public void setJaasSecurityManagerService(javax.management.ObjectName jaasSecurityManagerService)
Description copied from interface: BaseConnectionManager2MBean
Set the JaasSecurityManagerService value.

Specified by:
setJaasSecurityManagerService in interface BaseConnectionManager2MBean
Parameters:
jaasSecurityManagerService - The new JaasSecurityManagerService value.

getManagedConnectionFactory

public javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()
Description copied from interface: BaseConnectionManager2MBean
ManagedConnectionFactory is an internal attribute that holds the ManagedConnectionFactory instance managed by this ConnectionManager.

Specified by:
getManagedConnectionFactory in interface BaseConnectionManager2MBean
Returns:
value of managedConnectionFactory

getInstance

public BaseConnectionManager2 getInstance()
Description copied from interface: BaseConnectionManager2MBean
Describe getInstance method here.

Specified by:
getInstance in interface BaseConnectionManager2MBean
Returns:
a BaseConnectionManager2 value

getTimeLeftBeforeTransactionTimeout

public long getTimeLeftBeforeTransactionTimeout(boolean errorRollback)
                                         throws RollbackException
Specified by:
getTimeLeftBeforeTransactionTimeout in interface org.jboss.tm.TransactionTimeoutConfiguration
Throws:
RollbackException

getTransactionTimeout

public int getTransactionTimeout()
                          throws SystemException
Specified by:
getTransactionTimeout in interface org.jboss.tm.TransactionTimeoutConfiguration
Throws:
SystemException

startService

protected void startService()
                     throws Exception
Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

stopService

protected void stopService()
                    throws Exception
Overrides:
stopService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

getManagedConnection

public ConnectionListener getManagedConnection(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.

Parameters:
subject - a Subject value
cri - a ConnectionRequestInfo value
Returns:
a ManagedConnection value
Throws:
javax.resource.ResourceException - if an error occurs

getManagedConnection

protected ConnectionListener getManagedConnection(Transaction transaction,
                                                  Subject subject,
                                                  javax.resource.spi.ConnectionRequestInfo cri)
                                           throws javax.resource.ResourceException
Get the managed connection from the pool

Parameters:
transaction - the transaction for track by transaction
subject - the subject
cri - the ConnectionRequestInfo
Returns:
a managed connection
Throws:
javax.resource.ResourceException - if an error occurs

returnManagedConnection

public void returnManagedConnection(ConnectionListener cl,
                                    boolean kill)

getConnectionCount

public int getConnectionCount()

allocateConnection

public Object allocateConnection(javax.resource.spi.ManagedConnectionFactory mcf,
                                 javax.resource.spi.ConnectionRequestInfo cri)
                          throws javax.resource.ResourceException
Throws:
javax.resource.ResourceException

transactionStarted

public void transactionStarted(Collection conns)
                        throws SystemException
Description copied from interface: ConnectionCacheListener
Notification of transaction started

Specified by:
transactionStarted in interface ConnectionCacheListener
Parameters:
conns - the connections
Throws:
SystemException - for any error

reconnect

public void reconnect(Collection conns,
                      Set unsharableResources)
               throws javax.resource.ResourceException
Description copied from interface: ConnectionCacheListener
Notification to reconnect connections

Specified by:
reconnect in interface ConnectionCacheListener
Parameters:
conns - the connections
unsharableResources - unshareable resources
Throws:
javax.resource.ResourceException - for any error

disconnect

public void disconnect(Collection crs,
                       Set unsharableResources)
                throws javax.resource.ResourceException
Description copied from interface: ConnectionCacheListener
Notification to disconnect connections

Specified by:
disconnect in interface ConnectionCacheListener
Parameters:
crs - the connections
unsharableResources - the unshareable resources
Throws:
javax.resource.ResourceException - for any error

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster
Overrides:
getNotificationInfo in class org.jboss.mx.util.JBossNotificationBroadcasterSupport

unregisterAssociation

protected void unregisterAssociation(ConnectionListener cl,
                                     Object c)
                              throws javax.resource.ResourceException
Throws:
javax.resource.ResourceException

reconnectManagedConnection

protected void reconnectManagedConnection(ConnectionListener cl)
                                   throws javax.resource.ResourceException
Invoked to reassociate a managed connection

Parameters:
cl - the managed connection
Throws:
javax.resource.ResourceException

disconnectManagedConnection

protected void disconnectManagedConnection(ConnectionListener cl)
Invoked when a managed connection is no longer associated

Parameters:
cl - the managed connection

getCcm

protected final CachedConnectionManager getCcm()

managedConnectionReconnected

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

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

Throws:
javax.resource.ResourceException

managedConnectionDisconnected

protected void managedConnectionDisconnected(ConnectionListener cl)
                                      throws javax.resource.ResourceException
For polymorphism.

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

Throws:
javax.resource.ResourceException

isTransactional

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

Specified by:
isTransactional in interface ConnectionListenerFactory
Returns:
whether there is a transaction

getTransactionManagerInstance

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

Specified by:
getTransactionManagerInstance in interface ConnectionListenerFactory
Returns:
the transaction manager


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.