org.jboss.resource.connectionmanager
Class BaseConnectionManager2

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

public abstract class BaseConnectionManager2
extends ServiceMBeanSupport (src)
implements ConnectionCacheListener (src) , ConnectionListenerFactory (src)

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.


Nested Class Summary
protected  class BaseConnectionManager2.BaseConnectionEventListener (src)
           
static class BaseConnectionManager2.ConnectionManagerProxy (src)
           
 
Field Summary
protected  java.lang.String jndiName
           
protected  ManagedConnectionPool (src) poolingStrategy
           
static java.lang.String STOPPING_NOTIFICATION
           
protected  boolean 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
BaseConnectionManager2()
          Default BaseConnectionManager2 managed constructor for use by subclass mbeans.
BaseConnectionManager2(CachedConnectionManager (src)  ccm, ManagedConnectionPool (src)  poolingStrategy)
          Creates a new BaseConnectionManager2 instance.
 
Method Summary
 java.lang.Object allocateConnection(ManagedConnectionFactory (src)  mcf, ConnectionRequestInfo (src)  cri)
           
 void disconnect(java.util.Collection crs, java.util.Set unsharableResources)
           
protected  void disconnectManagedConnection(ConnectionListener (src)  cl)
          Invoked when a managed connection is no longer associated
 ObjectName (src) getCachedConnectionManager()
          Describe getCachedConnectionManager method here.
protected  CachedConnectionManager (src) getCcm()
           
 int getConnectionCount()
           
 BaseConnectionManager2 (src) getInstance()
          Describe getInstance method here.
 ObjectName (src) getJaasSecurityManagerService()
          Get the JaasSecurityManagerService value.
 java.lang.String getJndiName()
          The JndiName attribute holds the jndi name the ConnectionFactory will be bound under in jndi.
 ConnectionListener (src) getManagedConnection(javax.security.auth.Subject subject, ConnectionRequestInfo (src)  cri)
          Describe getManagedConnection method here.
protected  ConnectionListener (src) getManagedConnection(Transaction (src)  transaction, javax.security.auth.Subject subject, ConnectionRequestInfo (src)  cri)
          Get the managed connection from the pool
 ManagedConnectionFactory (src) getManagedConnectionFactory()
          ManagedConnectionFactory is an internal attribute that holds the ManagedConnectionFactory instance managed by this ConnectionManager.
 ObjectName (src) getManagedConnectionPool()
          The ManagedConnectionPool holds the ObjectName of the mbean representing the pool for this connection manager.
 MBeanNotificationInfo (src) [] getNotificationInfo()
          Returns the notification metadata associated with the MBean.
 ManagedConnectionPool (src) getPoolingStrategy()
          For testing
 java.lang.String getSecurityDomainJndiName()
          Get the SecurityDomainJndiName value.
 TransactionManager (src) getTransactionManagerInstance()
          Get the transaction manager
 boolean isTransactional()
          Determine whether is a transaction
protected  void managedConnectionDisconnected(ConnectionListener (src)  cl)
          For polymorphism.
protected  void managedConnectionReconnected(ConnectionListener (src)  cl)
          For polymorphism.
 void reconnect(java.util.Collection conns, java.util.Set unsharableResources)
          Describe reconnect method here.
protected  void reconnectManagedConnection(ConnectionListener (src)  cl)
          Invoked to reassociate a managed connection
protected static void rethrowAsResourceException(java.lang.String message, java.lang.Throwable t)
          Rethrow a throwable as resource exception
 void returnManagedConnection(ConnectionListener (src)  cl, boolean kill)
           
 void setCachedConnectionManager(ObjectName (src)  ccmName)
          The CachecConnectionManager holds the ObjectName of the CachedConnectionManager mbean used by this ConnectionManager.
 void setJaasSecurityManagerService(ObjectName (src)  jaasSecurityManagerService)
          Set the JaasSecurityManagerService value.
 void setJndiName(java.lang.String jndiName)
          Set the JndiName value.
 void setManagedConnectionPool(ObjectName (src)  newManagedConnectionPool)
          Set the ManagedConnectionPool value.
 void setSecurityDomainJndiName(java.lang.String securityDomainJndiName)
          The SecurityDomainJndiName holds the jndi name of the security domain configured for the ManagedConnectionFactory this ConnectionManager manages.
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 conns)
           
protected  void unregisterAssociation(ConnectionListener (src)  cl, java.lang.Object c)
           
 
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
 
Methods inherited from interface org.jboss.resource.connectionmanager.ConnectionListenerFactory (src)
createConnectionListener
 

Field Detail

STOPPING_NOTIFICATION

public static final java.lang.String STOPPING_NOTIFICATION
See Also:
Constant Field Values (src)

poolingStrategy

protected ManagedConnectionPool (src)  poolingStrategy

jndiName

protected java.lang.String jndiName

trace

protected boolean trace
Constructor Detail

BaseConnectionManager2

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


BaseConnectionManager2

public BaseConnectionManager2(CachedConnectionManager (src)  ccm,
                              ManagedConnectionPool (src)  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(java.lang.String message,
                                                 java.lang.Throwable t)
                                          throws ResourceException (src) 
Rethrow a throwable as resource exception

Throws:
ResourceException (src)

getPoolingStrategy

public ManagedConnectionPool (src)  getPoolingStrategy()
For testing


getJndiName

public java.lang.String getJndiName()
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.

Returns:
the JndiName value.

setJndiName

public void setJndiName(java.lang.String jndiName)
Set the JndiName value.

Parameters:
jndiName - The JndiName value.

getManagedConnectionPool

public ObjectName (src)  getManagedConnectionPool()
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.

Returns:
the ManagedConnectionPool value.

setManagedConnectionPool

public void setManagedConnectionPool(ObjectName (src)  newManagedConnectionPool)
Set the ManagedConnectionPool value.

Parameters:
newManagedConnectionPool - The new ManagedConnectionPool value.

setCachedConnectionManager

public void setCachedConnectionManager(ObjectName (src)  ccmName)
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.

Parameters:
ccmName - an ObjectName value

getCachedConnectionManager

public ObjectName (src)  getCachedConnectionManager()
Describe getCachedConnectionManager method here.

Returns:
an ObjectName value

setSecurityDomainJndiName

public void setSecurityDomainJndiName(java.lang.String securityDomainJndiName)
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.

Parameters:
securityDomainJndiName - an String value

getSecurityDomainJndiName

public java.lang.String getSecurityDomainJndiName()
Get the SecurityDomainJndiName value.

Returns:
the SecurityDomainJndiName value.

getJaasSecurityManagerService

public ObjectName (src)  getJaasSecurityManagerService()
Get the JaasSecurityManagerService value.

Returns:
the JaasSecurityManagerService value.

setJaasSecurityManagerService

public void setJaasSecurityManagerService(ObjectName (src)  jaasSecurityManagerService)
Set the JaasSecurityManagerService value.

Parameters:
jaasSecurityManagerService - The new JaasSecurityManagerService value.

getManagedConnectionFactory

public ManagedConnectionFactory (src)  getManagedConnectionFactory()
ManagedConnectionFactory is an internal attribute that holds the ManagedConnectionFactory instance managed by this ConnectionManager.

Returns:
value of managedConnectionFactory

getInstance

public BaseConnectionManager2 (src)  getInstance()
Describe getInstance method here.

Returns:
a BaseConnectionManager2 value

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 ServiceMBeanSupport (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 ServiceMBeanSupport (src)
Throws:
java.lang.Exception

getManagedConnection

public ConnectionListener (src)  getManagedConnection(javax.security.auth.Subject subject,
                                               ConnectionRequestInfo (src)  cri)
                                        throws ResourceException (src) 
Describe getManagedConnection method here. 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:
ResourceException (src) - if an error occurs

getManagedConnection

protected ConnectionListener (src)  getManagedConnection(Transaction (src)  transaction,
                                                  javax.security.auth.Subject subject,
                                                  ConnectionRequestInfo (src)  cri)
                                           throws ResourceException (src) 
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:
ResourceException (src) - if an error occurs

returnManagedConnection

public void returnManagedConnection(ConnectionListener (src)  cl,
                                    boolean kill)

getConnectionCount

public int getConnectionCount()

allocateConnection

public java.lang.Object allocateConnection(ManagedConnectionFactory (src)  mcf,
                                           ConnectionRequestInfo (src)  cri)
                                    throws ResourceException (src) 
Parameters:
mcf -
cri -
Returns:
Throws:
ResourceException (src) -

transactionStarted

public void transactionStarted(java.util.Collection conns)
                        throws SystemException (src) 
Specified by:
transactionStarted in interface ConnectionCacheListener (src)
Throws:
SystemException (src)

reconnect

public void reconnect(java.util.Collection conns,
                      java.util.Set unsharableResources)
               throws ResourceException (src) 
Describe reconnect method here.

Specified by:
reconnect in interface ConnectionCacheListener (src)
Parameters:
conns - a Collection value
Throws:
ResourceException (src) - if an error occurs

disconnect

public void disconnect(java.util.Collection crs,
                       java.util.Set unsharableResources)
                throws ResourceException (src) 
Specified by:
disconnect in interface ConnectionCacheListener (src)
Throws:
ResourceException (src)

getNotificationInfo

public MBeanNotificationInfo (src) [] getNotificationInfo()
Description copied from interface: NotificationBroadcaster (src)
Returns the notification metadata associated with the MBean.

Specified by:
getNotificationInfo in interface NotificationBroadcaster (src)
Overrides:
getNotificationInfo in class JBossNotificationBroadcasterSupport (src)
Returns:

unregisterAssociation

protected void unregisterAssociation(ConnectionListener (src)  cl,
                                     java.lang.Object c)
                              throws ResourceException (src) 
Throws:
ResourceException (src)

getCcm

protected final CachedConnectionManager (src)  getCcm()

reconnectManagedConnection

protected void reconnectManagedConnection(ConnectionListener (src)  cl)
                                   throws ResourceException (src) 
Invoked to reassociate a managed connection

Parameters:
cl - the managed connection
Throws:
ResourceException (src)

disconnectManagedConnection

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

Parameters:
cl - the managed connection

managedConnectionReconnected

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

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

Throws:
ResourceException (src)

managedConnectionDisconnected

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

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

Throws:
ResourceException (src)

isTransactional

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

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

getTransactionManagerInstance

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

Specified by:
getTransactionManagerInstance in interface ConnectionListenerFactory (src)
Returns:
the transaction manager