org.objectweb.cjdbc.controller.connection
Class RandomWaitPoolConnectionManager

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.connection.AbstractConnectionManager
      extended byorg.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager
          extended byorg.objectweb.cjdbc.controller.connection.RandomWaitPoolConnectionManager
All Implemented Interfaces:
java.io.Serializable

public class RandomWaitPoolConnectionManager
extends AbstractPoolConnectionManager
implements java.io.Serializable

This connection manager waits when the pool is empty. Requests are stacked using the Java wait/notify mechanism. Therefore the FIFO order is not guaranteed and the first request to get the freed connection is the thread that gets elected by the scheduler.

Version:
1.0
Author:
Emmanuel Cecchet, Nicolas Modrzyk
See Also:
Serialized Form

Field Summary
private  int timeout
          Time to wait for a connection in milliseconds (0 means wait forever).
 
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager
activeConnections, freeConnections, poolSize
 
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager
backendName, backendUrl, initialized, logger, rLogin, rPassword
 
Constructor Summary
RandomWaitPoolConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String login, java.lang.String password, int poolSize, int timeout)
          Creates a new RandomWaitPoolConnectionManager instance.
 
Method Summary
 java.sql.Connection getConnection()
          Gets a connection from the pool.
 java.lang.String getInformation()
          Gets information about this connection manager
 int getTimeout()
          Gets the timeout.
 java.lang.String getXmlInformation()
          Gets xml formatted information on this connection manager
 void releaseConnection(java.sql.Connection c)
          Releases a connection and puts it back to the pool.
 
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager
finalizeConnections, initializeConnections, initializeConnections
 
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager
finalize, getConnection, getLogin, getPassword, isInitialized, releaseConnection, retrieveConnection, setLogin, setPassword
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeout

private int timeout
Time to wait for a connection in milliseconds (0 means wait forever).

Constructor Detail

RandomWaitPoolConnectionManager

public RandomWaitPoolConnectionManager(java.lang.String backendUrl,
                                       java.lang.String backendName,
                                       java.lang.String login,
                                       java.lang.String password,
                                       int poolSize,
                                       int timeout)
Creates a new RandomWaitPoolConnectionManager 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
timeout - time to wait for a connection in seconds (0 means wait forever)
Method Detail

getTimeout

public int getTimeout()
Gets the timeout.

Returns:
a int value.

getConnection

public java.sql.Connection getConnection()
Gets a connection from the pool.

If the pool is empty, this methods blocks until a connection is freed or the timeout expires.

Specified by:
getConnection in class AbstractConnectionManager
Returns:
a connection from the pool or null if the timeout has expired.
See Also:
AbstractConnectionManager.getConnection()

releaseConnection

public void releaseConnection(java.sql.Connection c)
Description copied from class: AbstractPoolConnectionManager
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 AbstractPoolConnectionManager
Parameters:
c - the connection to release.
See Also:
AbstractPoolConnectionManager.releaseConnection(Connection)

getXmlInformation

public java.lang.String getXmlInformation()
Description copied from class: AbstractConnectionManager
Gets xml formatted information on this connection manager

Specified by:
getXmlInformation in class AbstractConnectionManager
Returns:
xml formatted string that conforms to c-jdbc.dtd
See Also:
AbstractConnectionManager.getXmlInformation()

getInformation

public java.lang.String getInformation()
Description copied from class: AbstractConnectionManager
Gets information about this connection manager

Specified by:
getInformation in class AbstractConnectionManager
Returns:
a String value containing information.
See Also:
AbstractConnectionManager.getInformation()


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