org.objectweb.jonas.resource
Class ConnectionManagerImpl

java.lang.Object
  |
  +--org.objectweb.jonas.resource.ConnectionManagerImpl
All Implemented Interfaces:
javax.resource.spi.ConnectionEventListener, org.objectweb.transaction.api.ConnectionManager, javax.resource.spi.ConnectionManager, java.util.EventListener, PoolMatchFactory, java.io.Serializable

public class ConnectionManagerImpl
extends java.lang.Object
implements javax.resource.spi.ConnectionEventListener, org.objectweb.transaction.api.ConnectionManager, PoolMatchFactory

Description of the ConnectionManagerImpl

Author:
chassand
See Also:
Serialized Form

Field Summary
static java.lang.String LOCAL_TRANS_SUPPORT
           
static java.lang.String LOGGER
          This constant is used in the by the init method
static java.lang.String LOGGER_FACTORY
          This constant is used in the by the init method
protected  java.util.Hashtable mc2mci
          This hashtable allows to find the list of connection handle associated to a ManagedConnection
protected  javax.resource.spi.ManagedConnectionFactory mcf
          The ManagedConnectionFactory instance which represents the resource adapter.
protected  int mcMaxPoolSize
          The max pool size of ManagedConnection.
protected  int mcMinPoolSize
          The min pool size of ManagedConnection.
protected  java.util.Vector mcs
          The list of managedConnection used without transaction
static java.lang.String NO_TRANS_SUPPORT
          These constants define the different transaction support values
protected  Pool poolMCs
          The pool of ManagedConnections associated to a ManagedConnectionFactory
static java.lang.String PRINT_WRITER
          This constant is used in the by the init method
static java.lang.String RESOURCE_ADAPTER
          This constant is used in the by the init method
static java.lang.String RESOURCE_BUNDLE_NAME
          This constant is used in the by the init method
static java.lang.String RESOURCE_MANAGER_EVENT_LISTENER
          This constant is used in the by the init method
protected  java.lang.String resourceBundleName
           
protected  org.objectweb.transaction.api.ResourceManagerEventListener rmel
          This variable is used by the server to register connections when no transactionnal context exists
protected  ResourceSpec rs
          This is a cache to the last instance of ResourceSpec used by the ConnectionManager.
protected  java.util.Vector synchros
          The list of Synchronisation instance managed in this ConnectionManager
protected  javax.transaction.TransactionManager tm
          The transaction manager in server
protected  org.objectweb.util.monolog.api.Logger trace
          The Logger instance where messages are written.
static java.lang.String TRANSACTION_MANAGER
          This constant is used in the by the init method
protected  java.lang.String transSupport
          The holds the transaction support level for the associated RAR file
protected  java.util.Hashtable usedMCs
          The list of used ManagedConnections key = transaction reference value = MCInfo
static java.lang.String XA_TRANS_SUPPORT
           
 
Constructor Summary
ConnectionManagerImpl(java.lang.String _transSupport)
           
 
Method Summary
 java.lang.Object allocateConnection(javax.resource.spi.ManagedConnectionFactory _mcf, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
          The method allocateConnection gets called by the resource adapter's connection factory instance. see javax.resource.cci.ConnectionManager
 void checkManagedConnection(javax.resource.spi.ManagedConnectionFactory mcf, javax.resource.spi.ManagedConnection current, java.lang.Object connection, javax.resource.spi.ConnectionRequestInfo cri)
          see org.objectweb.transaction.api..ConnectionManager
 void cleanResourceAdapter()
          Description of the Method
 void connectionClosed(javax.resource.spi.ConnectionEvent event)
          IMPLEMENTATION OF INTERFACE ConnectionEventListener * A ManagedConnection instance calls the connectionClosed method to notify its registered set of listeners when an application component closes a connection handle.
 void connectionErrorOccurred(javax.resource.spi.ConnectionEvent event)
          The connectionErrorOccurred method indicates that the associated ManagedConnection instance is now invalid and unusable.
 java.lang.Object createResource(java.lang.Object hints)
          Call the ManagedConnectionFactory in order to create a new instance. of ManagedConnection.
protected  java.lang.String getState(java.lang.String prefix)
          Gets the State attribute of the ConnectionManagerImpl object
 void init(javax.naming.Context ctx)
          This method permits to initialize the ConnectionManager with the following parameter: RESOURCE_BUNDLE_NAME: The name of the resource bundle in order to internationalize the logging LOGGER: The logger instance where events are logged LOGGER_FACTORY: A logger factory to obtain a logger PRINT_WRITER: The printwriter where event are logged TRANSACTION_MANAGER: The Transaction manager linked to this resource manager RESOURCE_MANAGER_EVENT_LISTENER: The resource manage event listener which subscribed to later connection enlistement.
 void localTransactionCommitted(javax.resource.spi.ConnectionEvent event)
          Notifies that a Resource Manager Local Transaction was committed on the ManagedConnection instance. see javax.resource.spi.ConnectionEventListener
 void localTransactionRolledback(javax.resource.spi.ConnectionEvent event)
          Notifies that a Resource Manager Local Transaction was rolled back on the ManagedConnection instance. see javax.resource.spi.ConnectionEventListener
 void localTransactionStarted(javax.resource.spi.ConnectionEvent event)
          Notifies that a Resource Manager Local Transaction was started on the ManagedConnection instance. see javax.resource.spi.ConnectionEventListener
 boolean matchResource(java.lang.Object res, java.lang.Object hints)
          All method of the pool match to the right type of ManagedConnection because there is one pool by ManagedConnectionFactory. see org.objectweb.util.pool.api.PoolMatchFactory
 java.lang.Object matchResource(java.util.Set res, java.lang.Object hints)
          All method of the pool match to the right type of ManagedConnection because there is one pool by ManagedConnectionFactory. see org.objectweb.util.pool.api.PoolMatchFactory
 void setLogger(org.objectweb.util.monolog.api.Logger l)
          Setters method to initialize the ConnectionManager The logger instance where events are logged
 void setLoggerFactory(org.objectweb.util.monolog.api.LoggerFactory lf)
          Setters method to initialize the ConnectionManager A logger factory to obtain a logger
 void setPrintWriter(java.io.PrintWriter pw)
          Setters method to initialize the ConnectionManager The printwriter where event are logged
 void setResourceAdapter(javax.resource.spi.ManagedConnectionFactory _mcf)
          Setters method to initialize the ConnectionManager The managedConnectionFactory instance of the resource which must be maneged by this connectionManager
 void setResourceAdapter(javax.resource.spi.ManagedConnectionFactory _mcf, int initPoolSize, int minPoolSize, int maxPoolSize)
          Setters method to initialize the ConnectionManager The managedConnectionFactory instance of the resource which must be maneged by this connectionManager
 void setResourceManagerEventListener(org.objectweb.transaction.api.ResourceManagerEventListener _rmel)
          Setters method to initialize the ConnectionManager The logger instance where events are logged
 void setTransactionManager(javax.transaction.TransactionManager _tm)
          Setters method to initialize the ConnectionManager The Transaction manager linked to this resource managed
 java.lang.String toString()
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

trace

protected org.objectweb.util.monolog.api.Logger trace
The Logger instance where messages are written.

rmel

protected org.objectweb.transaction.api.ResourceManagerEventListener rmel
This variable is used by the server to register connections when no transactionnal context exists

resourceBundleName

protected java.lang.String resourceBundleName

tm

protected javax.transaction.TransactionManager tm
The transaction manager in server

mc2mci

protected java.util.Hashtable mc2mci
This hashtable allows to find the list of connection handle associated to a ManagedConnection

mcMaxPoolSize

protected int mcMaxPoolSize
The max pool size of ManagedConnection. The default value is 100.

mcMinPoolSize

protected int mcMinPoolSize
The min pool size of ManagedConnection. The default value is 0

mcf

protected javax.resource.spi.ManagedConnectionFactory mcf
The ManagedConnectionFactory instance which represents the resource adapter.

poolMCs

protected Pool poolMCs
The pool of ManagedConnections associated to a ManagedConnectionFactory

usedMCs

protected java.util.Hashtable usedMCs
The list of used ManagedConnections key = transaction reference value = MCInfo

mcs

protected java.util.Vector mcs
The list of managedConnection used without transaction

synchros

protected java.util.Vector synchros
The list of Synchronisation instance managed in this ConnectionManager

rs

protected ResourceSpec rs
This is a cache to the last instance of ResourceSpec used by the ConnectionManager. Indeed this instance is always the same.

transSupport

protected java.lang.String transSupport
The holds the transaction support level for the associated RAR file

RESOURCE_BUNDLE_NAME

public static final java.lang.String RESOURCE_BUNDLE_NAME
This constant is used in the by the init method

LOGGER

public static final java.lang.String LOGGER
This constant is used in the by the init method

LOGGER_FACTORY

public static final java.lang.String LOGGER_FACTORY
This constant is used in the by the init method

TRANSACTION_MANAGER

public static final java.lang.String TRANSACTION_MANAGER
This constant is used in the by the init method

RESOURCE_MANAGER_EVENT_LISTENER

public static final java.lang.String RESOURCE_MANAGER_EVENT_LISTENER
This constant is used in the by the init method

RESOURCE_ADAPTER

public static final java.lang.String RESOURCE_ADAPTER
This constant is used in the by the init method

PRINT_WRITER

public static final java.lang.String PRINT_WRITER
This constant is used in the by the init method

NO_TRANS_SUPPORT

public static final java.lang.String NO_TRANS_SUPPORT
These constants define the different transaction support values

LOCAL_TRANS_SUPPORT

public static final java.lang.String LOCAL_TRANS_SUPPORT

XA_TRANS_SUPPORT

public static final java.lang.String XA_TRANS_SUPPORT
Constructor Detail

ConnectionManagerImpl

public ConnectionManagerImpl(java.lang.String _transSupport)
Method Detail

setLogger

public void setLogger(org.objectweb.util.monolog.api.Logger l)
Setters method to initialize the ConnectionManager The logger instance where events are logged
Parameters:
l - The new Logger value

setLoggerFactory

public void setLoggerFactory(org.objectweb.util.monolog.api.LoggerFactory lf)
Setters method to initialize the ConnectionManager A logger factory to obtain a logger
Parameters:
lf - The new LoggerFactory value

setPrintWriter

public void setPrintWriter(java.io.PrintWriter pw)
Setters method to initialize the ConnectionManager The printwriter where event are logged
Parameters:
pw - The new PrintWriter value

setResourceManagerEventListener

public void setResourceManagerEventListener(org.objectweb.transaction.api.ResourceManagerEventListener _rmel)
Setters method to initialize the ConnectionManager The logger instance where events are logged
Parameters:
_rmel - The new ResourceManagerEventListener value

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager _tm)
Setters method to initialize the ConnectionManager The Transaction manager linked to this resource managed
Parameters:
_tm - The new TransactionManager value

setResourceAdapter

public void setResourceAdapter(javax.resource.spi.ManagedConnectionFactory _mcf)
                        throws java.lang.Exception
Setters method to initialize the ConnectionManager The managedConnectionFactory instance of the resource which must be maneged by this connectionManager
Parameters:
_mcf - The new ResourceAdapter value
Throws:
java.lang.Exception - Description of Exception

setResourceAdapter

public void setResourceAdapter(javax.resource.spi.ManagedConnectionFactory _mcf,
                               int initPoolSize,
                               int minPoolSize,
                               int maxPoolSize)
                        throws java.lang.Exception
Setters method to initialize the ConnectionManager The managedConnectionFactory instance of the resource which must be maneged by this connectionManager
Parameters:
_mcf - The new ResourceAdapter value
initPoolSize - The initial pool size int to set for non-pool provider
minPoolSize - The min pool size int to set for non-pool provider
maxPoolSize - The max pool size int to set for non-pool provider
Throws:
java.lang.Exception - Description of Exception

init

public void init(javax.naming.Context ctx)
          throws java.lang.Exception
This method permits to initialize the ConnectionManager with the following parameter: RESOURCE_BUNDLE_NAME: The name of the resource bundle in order to internationalize the logging LOGGER: The logger instance where events are logged LOGGER_FACTORY: A logger factory to obtain a logger PRINT_WRITER: The printwriter where event are logged TRANSACTION_MANAGER: The Transaction manager linked to this resource manager RESOURCE_MANAGER_EVENT_LISTENER: The resource manage event listener which subscribed to later connection enlistement. RESOURCE_ADAPTER: The managedConnectionFactory instance of the resource which must be maneged by this connectionManager
Parameters:
ctx - Description of Parameter
Throws:
java.lang.Exception - Description of Exception

cleanResourceAdapter

public void cleanResourceAdapter()
                          throws javax.resource.ResourceException
Description of the Method
Throws:
javax.resource.ResourceException - Description of Exception

allocateConnection

public java.lang.Object allocateConnection(javax.resource.spi.ManagedConnectionFactory _mcf,
                                           javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
                                    throws javax.resource.ResourceException
The method allocateConnection gets called by the resource adapter's connection factory instance. see javax.resource.cci.ConnectionManager
Specified by:
allocateConnection in interface javax.resource.spi.ConnectionManager

checkManagedConnection

public void checkManagedConnection(javax.resource.spi.ManagedConnectionFactory mcf,
                                   javax.resource.spi.ManagedConnection current,
                                   java.lang.Object connection,
                                   javax.resource.spi.ConnectionRequestInfo cri)
                            throws javax.resource.ResourceException
see org.objectweb.transaction.api..ConnectionManager
Specified by:
checkManagedConnection in interface org.objectweb.transaction.api.ConnectionManager

matchResource

public boolean matchResource(java.lang.Object res,
                             java.lang.Object hints)
All method of the pool match to the right type of ManagedConnection because there is one pool by ManagedConnectionFactory. see org.objectweb.util.pool.api.PoolMatchFactory
Specified by:
matchResource in interface PoolMatchFactory
Following copied from interface: org.objectweb.jonas.resource.pool.api.PoolMatchFactory
Parameters:
pr - The Object to test its matching with some "properties" specified by hints.
hints - The "properties" that the Object specified by pr should match.
Returns:
true if the pr Object matches the hints "properties".

matchResource

public java.lang.Object matchResource(java.util.Set res,
                                      java.lang.Object hints)
                               throws java.lang.Exception
All method of the pool match to the right type of ManagedConnection because there is one pool by ManagedConnectionFactory. see org.objectweb.util.pool.api.PoolMatchFactory
Specified by:
matchResource in interface PoolMatchFactory
Following copied from interface: org.objectweb.jonas.resource.pool.api.PoolMatchFactory
Parameters:
res - A set of Objects to test if matching with some "properties" specified by hints.
hints - The "properties" that the Object specified by pr should match.
Returns:
Object that matches the hints "properties". or null if no match.
Throws:
java.lang.Exception - Description of Exception

createResource

public java.lang.Object createResource(java.lang.Object hints)
                                throws java.lang.Exception
Call the ManagedConnectionFactory in order to create a new instance. of ManagedConnection. The Object is a ManagedConnection instance. The hints is a local structure: ResourceSpec see org.objectweb.util.pool.api.PoolMatchFactory
Specified by:
createResource in interface PoolMatchFactory
Following copied from interface: org.objectweb.jonas.resource.pool.api.PoolMatchFactory
Parameters:
hints - The "properties" that the created Object should conform to.
Returns:
The created Object.

connectionClosed

public void connectionClosed(javax.resource.spi.ConnectionEvent event)
IMPLEMENTATION OF INTERFACE ConnectionEventListener * A ManagedConnection instance calls the connectionClosed method to notify its registered set of listeners when an application component closes a connection handle. The application server uses this connection close event to make a decision on whether or not to put the ManagedConnection instance back into the connection pool. see javax.resource.spi.ConnectionEventListener
Specified by:
connectionClosed in interface javax.resource.spi.ConnectionEventListener

connectionErrorOccurred

public void connectionErrorOccurred(javax.resource.spi.ConnectionEvent event)
The connectionErrorOccurred method indicates that the associated ManagedConnection instance is now invalid and unusable. The application server handles the connection error event notification by initiating application server-specific cleanup (for example, removing ManagedConnection instance from the connection pool) and then calling ManagedConnection.destroy method to destroy the physical connection.. see javax.resource.spi.ConnectionEventListener
Specified by:
connectionErrorOccurred in interface javax.resource.spi.ConnectionEventListener

localTransactionCommitted

public void localTransactionCommitted(javax.resource.spi.ConnectionEvent event)
Notifies that a Resource Manager Local Transaction was committed on the ManagedConnection instance. see javax.resource.spi.ConnectionEventListener
Specified by:
localTransactionCommitted in interface javax.resource.spi.ConnectionEventListener

localTransactionRolledback

public void localTransactionRolledback(javax.resource.spi.ConnectionEvent event)
Notifies that a Resource Manager Local Transaction was rolled back on the ManagedConnection instance. see javax.resource.spi.ConnectionEventListener
Specified by:
localTransactionRolledback in interface javax.resource.spi.ConnectionEventListener

localTransactionStarted

public void localTransactionStarted(javax.resource.spi.ConnectionEvent event)
Notifies that a Resource Manager Local Transaction was started on the ManagedConnection instance. see javax.resource.spi.ConnectionEventListener
Specified by:
localTransactionStarted in interface javax.resource.spi.ConnectionEventListener

toString

public java.lang.String toString()
Description of the Method
Overrides:
toString in class java.lang.Object
Returns:
Description of the Returned Value

getState

protected java.lang.String getState(java.lang.String prefix)
Gets the State attribute of the ConnectionManagerImpl object
Parameters:
prefix - Description of Parameter
Returns:
The State value