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.io.Serializable
Direct Known Subclasses:
FailFastPoolConnectionManager, RandomWaitPoolConnectionManager, VariablePoolConnectionManager

public abstract class AbstractPoolConnectionManager
extends AbstractConnectionManager
implements java.io.Serializable

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(java.sql.Connection) from AbstractConnectionManager).

Version:
1.0
Author:
Emmanuel Cecchet, Mathieu Peltier
See Also:
Serialized Form

Field Summary
protected  java.util.Vector activeConnections
          Pool of currently used connections (Vector type because synchronisation is needed).
protected  java.util.Stack 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, initialized, logger, rLogin, rPassword
 
Constructor Summary
AbstractPoolConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String login, java.lang.String password, int poolSize)
          Creates a new AbstractPoolConnectionManager instance.
 
Method Summary
 void finalizeConnections()
          Releases all the connections to the database.
 void initializeConnections()
          Initializes the connection(s) to the database.
 void initializeConnections(int initPoolSize)
          Initialize initPoolSize connections in the pool.
abstract  void releaseConnection(java.sql.Connection connection)
          Releases a connection and puts it back to the pool.
 
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager
finalize, getConnection, getConnection, getInformation, getLogin, getPassword, getXmlInformation, isInitialized, releaseConnection, retrieveConnection, setLogin, setPassword
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

freeConnections

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


activeConnections

protected transient java.util.Vector 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,
                                     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.
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()

releaseConnection

public abstract void releaseConnection(java.sql.Connection connection)
Releases a connection and puts it back to the pool. Note that the connection is not closed but only returns to the free connections pool.

Specified by:
releaseConnection in class AbstractConnectionManager
Parameters:
connection - the connection to release.


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