Class PooledConnectionFactory
- java.lang.Object
-
- org.objectweb.joram.client.jms.pool.PooledConnectionFactory
-
- All Implemented Interfaces:
ConnectionFactory
public class PooledConnectionFactory extends Object implements ConnectionFactory
A ConnectionFactory which pools Connection for reuse.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intallocatedcnx(package private) ConnectionFactorycfThe underlying ConnectionFactory(package private) intcreatedCnx(package private) intfreedCnx(package private) intmaxFreeConnectionsThe maximum number of free connections for an identity in the pool.(package private) intmaxUsedCnx(package private) ConnectionPoolpoolThe pool of connections
-
Constructor Summary
Constructors Constructor Description PooledConnectionFactory(ConnectionFactory cf)Creates a new pool for the specified ConnectionFactory.PooledConnectionFactory(ConnectionFactory cf, int maxFreeConnections)Creates a new pool for the specified ConnectionFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectioncreateConnection()API method, creates a connection with the default user identity.ConnectioncreateConnection(String name, String password)API method, creates a connection with the specified user identity.protected ConnectionPoolcreateConnectionPool(int maxFreeConnections)JMSContextcreateContext()JMSContextcreateContext(int sessionMode)JMSContextcreateContext(String userName, String password)JMSContextcreateContext(String userName, String password, int sessionMode)(package private) voidfree(PooledConnection cnx)ConnectionFactorygetConnectionFactory()Returns the underlying ConnectionFactory used to create the connections.intgetMaxFreeConnections()Returns the maximum number of free connections for an identity in the pool.StringgetStatistics()voidsetMaxFreeConnections(int maxFreeConnections)Sets the maximum number of free connections for an identity in the pool.
-
-
-
Field Detail
-
cf
ConnectionFactory cf
The underlying ConnectionFactory
-
pool
ConnectionPool pool
The pool of connections
-
maxFreeConnections
int maxFreeConnections
The maximum number of free connections for an identity in the pool.
-
createdCnx
int createdCnx
-
allocatedcnx
int allocatedcnx
-
freedCnx
int freedCnx
-
maxUsedCnx
int maxUsedCnx
-
-
Constructor Detail
-
PooledConnectionFactory
public PooledConnectionFactory(ConnectionFactory cf)
Creates a new pool for the specified ConnectionFactory.- Parameters:
cf- The ConnectionFactory used to really create the connections.
-
PooledConnectionFactory
public PooledConnectionFactory(ConnectionFactory cf, int maxFreeConnections)
Creates a new pool for the specified ConnectionFactory.- Parameters:
cf- The ConnectionFactory used to really create the connections.maxFreeConnections- The maximum number of free connections for an identity in the pool.
-
-
Method Detail
-
getConnectionFactory
public ConnectionFactory getConnectionFactory()
Returns the underlying ConnectionFactory used to create the connections. This ConnectionFactory object allows to configure the created connections.- Returns:
- the underlying ConnectionFactory.
-
getMaxFreeConnections
public int getMaxFreeConnections()
Returns the maximum number of free connections for an identity in the pool.- Returns:
- The maximum number of free connections in the pool.
-
setMaxFreeConnections
public void setMaxFreeConnections(int maxFreeConnections)
Sets the maximum number of free connections for an identity in the pool.- Parameters:
maxFreeConnections- the maximum number of free connections to set
-
createConnection
public Connection createConnection() throws JMSException
API method, creates a connection with the default user identity. The connection is created in stopped mode.- Specified by:
createConnectionin interfaceConnectionFactory- Returns:
- a newly created connection.
- Throws:
JMSSecurityException- If the default identification is incorrect.IllegalStateException- If the server is not listening.JMSException- See Also:
ConnectionFactory.createConnection()
-
getStatistics
public String getStatistics()
-
createConnection
public Connection createConnection(String name, String password) throws JMSException
API method, creates a connection with the specified user identity. The connection is created in stopped mode.- Specified by:
createConnectionin interfaceConnectionFactory- Parameters:
name- the caller's user name.password- the caller's password.- Returns:
- a newly created connection.
- Throws:
JMSSecurityException- If the user identification is incorrect.IllegalStateException- If the server is not listening.JMSException- See Also:
ConnectionFactory.createConnection(String, String)
-
free
void free(PooledConnection cnx) throws JMSException
- Parameters:
cnx-- Throws:
JMSException
-
createConnectionPool
protected ConnectionPool createConnectionPool(int maxFreeConnections)
- Parameters:
maxFreeConnections- The maximum number of free connections for an identity in the pool.- Returns:
- The
-
createContext
public JMSContext createContext()
- Specified by:
createContextin interfaceConnectionFactory
-
createContext
public JMSContext createContext(String userName, String password)
- Specified by:
createContextin interfaceConnectionFactory
-
createContext
public JMSContext createContext(String userName, String password, int sessionMode)
- Specified by:
createContextin interfaceConnectionFactory
-
createContext
public JMSContext createContext(int sessionMode)
- Specified by:
createContextin interfaceConnectionFactory
-
-