org.objectweb.cjdbc.controller.connection
Class AbstractPoolConnectionManager

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.connection.AbstractConnectionManager
      extended byorg.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager
All Implemented Interfaces:
java.lang.Cloneable, XmlComponent
Direct Known Subclasses:
FailFastPoolConnectionManager, RandomWaitPoolConnectionManager, VariablePoolConnectionManager

public abstract class AbstractPoolConnectionManager
extends AbstractConnectionManager

This connection manager uses a pool of persistent connections with the database. The allocation/release policy is implemented by the subclasses (abstract AbstractConnectionManager.getConnection()/ AbstractConnectionManager.releaseConnection(Connection) from AbstractConnectionManager).

Version:
1.0
Author:
Emmanuel Cecchet , Mathieu Peltier

Field Summary
protected  java.util.ArrayList activeConnections
          Pool of currently used connections (Vector type because synchronisation is needed).
protected  java.util.LinkedList freeConnections
          Stack of available connections (pool).
protected  int poolSize
          Size of the connection pool with the real database.
 
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager
backendName, backendUrl, driverClassName, driverPath, initialized, logger, rLogin, rPassword
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION
 
Constructor Summary
AbstractPoolConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String login, java.lang.String password, java.lang.String driverPath, java.lang.String driverClassName, int poolSize)
          Creates a new AbstractPoolConnectionManager instance.
 
Method Summary
 void finalizeConnections()
          Releases all the connections to the database.
 int getCurrentNumberOfConnections()
          Get the current number of connections open for this connection manager.
 void initializeConnections()
          Initializes the connection(s) to the database.
 void initializeConnections(int initPoolSize)
          Initialize initPoolSize connections in the pool.
 
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager
clone, copy, deleteConnection, deleteConnection, finalize, getConnection, getConnection, getConnectionFromDriver, getDriverClassName, getDriverPath, getLogin, getPassword, getVLogin, getXml, getXmlImpl, isInitialized, releaseConnection, releaseConnection, retrieveConnection, setDriverClassName, setDriverPath, setLogin, setPassword, setVLogin
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

freeConnections

protected transient java.util.LinkedList freeConnections
Stack of available connections (pool).


activeConnections

protected transient java.util.ArrayList activeConnections
Pool of currently used connections (Vector type because synchronisation is needed).


poolSize

protected int poolSize
Size of the connection pool with the real database.

Constructor Detail

AbstractPoolConnectionManager

public AbstractPoolConnectionManager(java.lang.String backendUrl,
                                     java.lang.String backendName,
                                     java.lang.String login,
                                     java.lang.String password,
                                     java.lang.String driverPath,
                                     java.lang.String driverClassName,
                                     int poolSize)
Creates a new AbstractPoolConnectionManager instance.

Parameters:
backendUrl - URL of the DatabaseBackend owning this connection manager.
backendName - name of the DatabaseBackend owning this connection manager.
login - backend connection login to be used by this connection manager.
password - backend connection password to be used by this connection manager.
driverPath - path for driver
driverClassName - class name for driver
poolSize - size of the connection pool.
Method Detail

initializeConnections

public void initializeConnections()
                           throws java.sql.SQLException
Description copied from class: AbstractConnectionManager
Initializes the connection(s) to the database. The caller must ensure that the driver has already been loaded else an exception will be thrown.

Specified by:
initializeConnections in class AbstractConnectionManager
Throws:
java.sql.SQLException - if an error occurs.
See Also:
AbstractConnectionManager.initializeConnections()

initializeConnections

public void initializeConnections(int initPoolSize)
                           throws java.sql.SQLException
Initialize initPoolSize connections in the pool.

Parameters:
initPoolSize - number of connections to initialize
Throws:
java.sql.SQLException - if an error occurs

finalizeConnections

public void finalizeConnections()
                         throws java.sql.SQLException
Description copied from class: AbstractConnectionManager
Releases all the connections to the database.

Specified by:
finalizeConnections in class AbstractConnectionManager
Throws:
java.sql.SQLException - if an error occurs.
See Also:
AbstractConnectionManager.finalizeConnections()

getCurrentNumberOfConnections

public int getCurrentNumberOfConnections()
Description copied from class: AbstractConnectionManager
Get the current number of connections open for this connection manager.

Specified by:
getCurrentNumberOfConnections in class AbstractConnectionManager
Returns:
the current number of open connections
See Also:
AbstractConnectionManager.getCurrentNumberOfConnections()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.