info.aduna.gee.publication.servlets.jdbc
Class ConnectionPool

java.lang.Object
  extended by info.aduna.gee.publication.servlets.jdbc.ConnectionPool

public class ConnectionPool
extends Object

Class ConnectionPool manages a pool of connections to the database for a certain (virtual) host. Clients can try to get a connection, optionally wait until one becomes available, get the connection, do something with it and return the connection to the pool. Note that the ConnectionPool decides whether or not to reuse connections. The current implementation does not reuse connections.


Field Summary
protected  String _dbURL
           
protected  int _freeConnections
          Available number of connections
protected  int _numberOfConnections
          Maximum number of connections
protected  ArrayList _requestQueue
          Clients that should be notified when a connection becomes available.
static Object ABORT
           
static Object WAIT
           
 
Constructor Summary
ConnectionPool(String host, boolean useInProcessDatabase)
          Construct a new ConnectionPool for the specified host.
 
Method Summary
protected  Connection _getNewConnection(String name, String password)
           
 Object getConnection(Object client)
          Get a connection for the specified client.
 void returnConnection(Connection connection)
          Return a connection to the pool of free connections; if there is a waiting client, notify it.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WAIT

public static final Object WAIT

ABORT

public static final Object ABORT

_dbURL

protected String _dbURL

_numberOfConnections

protected int _numberOfConnections
Maximum number of connections


_freeConnections

protected int _freeConnections
Available number of connections


_requestQueue

protected ArrayList _requestQueue
Clients that should be notified when a connection becomes available.

Constructor Detail

ConnectionPool

public ConnectionPool(String host,
                      boolean useInProcessDatabase)
Construct a new ConnectionPool for the specified host.

Parameters:
host - The name of the host.
Method Detail

size

public int size()
Returns:
the total amount of connections managed by this pool.

getConnection

public Object getConnection(Object client)
Get a connection for the specified client. The client should take care to return the connection upon completion.

Returns:
either a Connection, WAIT or ABORT
See Also:
returnConnection(java.sql.Connection)

returnConnection

public void returnConnection(Connection connection)
Return a connection to the pool of free connections; if there is a waiting client, notify it.

Parameters:
connection - The connection to return to the pool.

_getNewConnection

protected Connection _getNewConnection(String name,
                                       String password)
Returns:
a new connection to the database, or null if there was some problem connecting to the database


Copyright © 1997-2008 Aduna. All Rights Reserved.