org.objectweb.jonas.dbm
Class Pool

java.lang.Object
  extended byorg.objectweb.jonas.dbm.Pool

public class Pool
extends java.lang.Object

Connection Pool

Author:
Philippe Durieux

Contributor(s):

  1. Markus Fritz
  2. 01/11/06 Christophe Ney cney@batisseurs.com for Lutris Technologies Added ResourceManagerListener mechanism to remove ThreadData dependency.
  3. 02/01/15 Dean Jennings - Map instead of Hashtable for tx2item and xac2item
  4. 03/05/15 Adriana Danes - Introduce pool size configuration

Constructor Summary
Pool(ConnectionManager cmgr, XADataSourceImpl xads)
          Pool constructor
 
Method Summary
 void check4MaxAge()
          Check all connections not in a transaction if their maxage is reached and if so kill them.
 void closeAllConnections()
          Close all connections in the pool, when server is shut down.
 PoolItem closeConnection(javax.sql.XAConnection xac, int flag)
          Mark a specific Connection in the pool as closed.
 void freeConnections(javax.transaction.Transaction tx)
          The transaction has committed (or rolled back).
 int getCurrentNumberOfXAConnection()
          Management method:
protected  int getMaxConnPool()
           
protected  int getMinConnPool()
           
 PoolItem newConnection(java.lang.String user, javax.transaction.Transaction tx)
          Add a new XAConnection in the pool
 PoolItem openConnection(java.lang.String user, javax.transaction.Transaction tx)
          lookup connection in the pool for this user/tx
protected  int setConnCheckLevel(int jdbcConnCheckLevel)
           
protected  long setConnMaxAge(long jdbcConnMaxAge)
           
protected  int setMaxConnPool(int maxConPool)
           
protected  int setMinConnPool(int minConPool)
           
protected  java.lang.String setTestStatement(java.lang.String jdbcTestStmt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pool

public Pool(ConnectionManager cmgr,
            XADataSourceImpl xads)
     throws java.lang.Exception
Pool constructor

Parameters:
xads - XA DataSource implementation created by this pool's Connection manager. Allows for getting XA Connections.
cmgr - the pool's Connection manager has to be registered as ConnectionEventListener of the XA connections created at the pool creation
Method Detail

setConnCheckLevel

protected int setConnCheckLevel(int jdbcConnCheckLevel)

setConnMaxAge

protected long setConnMaxAge(long jdbcConnMaxAge)
Parameters:
jdbcConnMaxAge - max age of connection in minutes

setTestStatement

protected java.lang.String setTestStatement(java.lang.String jdbcTestStmt)

setMinConnPool

protected int setMinConnPool(int minConPool)
                      throws ServiceException
Throws:
ServiceException

setMaxConnPool

protected int setMaxConnPool(int maxConPool)

getMaxConnPool

protected int getMaxConnPool()

getMinConnPool

protected int getMinConnPool()

openConnection

public PoolItem openConnection(java.lang.String user,
                               javax.transaction.Transaction tx)
                        throws java.sql.SQLException
lookup connection in the pool for this user/tx

Parameters:
user - user name
tx - Transaction the connection is involved
Returns:
the free PoolItem or null if no item available
Throws:
java.sql.SQLException

newConnection

public PoolItem newConnection(java.lang.String user,
                              javax.transaction.Transaction tx)
                       throws java.sql.SQLException
Add a new XAConnection in the pool

Parameters:
user - user name
tx - Transaction the connection is involved
Throws:
java.sql.SQLException

freeConnections

public void freeConnections(javax.transaction.Transaction tx)
The transaction has committed (or rolled back). We can return its connections to the pool of available connections.

Parameters:
tx - the non null transaction

closeConnection

public PoolItem closeConnection(javax.sql.XAConnection xac,
                                int flag)
Mark a specific Connection in the pool as closed. If it is no longer associated to a Tx, we can free it.

Returns:
the PoolItem the connection is in (=> tx) or null if error.

check4MaxAge

public void check4MaxAge()
Check all connections not in a transaction if their maxage is reached and if so kill them.


closeAllConnections

public void closeAllConnections()
Close all connections in the pool, when server is shut down.


getCurrentNumberOfXAConnection

public int getCurrentNumberOfXAConnection()
Management method:

Returns:
int number of xa connection