org.glite.security.voms.database.connection
Class ConnectionPool

java.lang.Object
  extended byorg.glite.security.voms.database.connection.ConnectionPool

public final class ConnectionPool
extends java.lang.Object

A trivial database connection pool implementation. TODO: replace this hack with JNDI/JDBC-based real connection pools.

Author:
Karoly Lorentey

Method Summary
 boolean closeAll()
          Close all free database connections.
 void forget(java.sql.Connection c)
          Release a failed connection, i.e. close it and forget about it.
 java.sql.Connection get(boolean dontwait)
          Allocate a Connection object from the connection pool and return it.
static ConnectionPool getInstance()
          Factory method.
 void release(java.sql.Connection c)
          Put a Connection back to the connection pool.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static ConnectionPool getInstance()
                                  throws GeneralDatabaseException
Factory method.

Throws:
GeneralDatabaseException

get

public java.sql.Connection get(boolean dontwait)
                        throws VOMSException
Allocate a Connection object from the connection pool and return it.

Parameters:
dontwait - If true, ignore connection limits and create a new connection if necessary without waiting.
Throws:
GeneralDatabaseException - if a database error prevented the allocation of a connection.
VOMSException

release

public void release(java.sql.Connection c)
Put a Connection back to the connection pool.


forget

public void forget(java.sql.Connection c)
Release a failed connection, i.e. close it and forget about it.


toString

public java.lang.String toString()

closeAll

public boolean closeAll()
Close all free database connections. This method is intended to be called during service shutdown. Note that it does not free connections which are currently in use.

Returns:
true if all connections were closed.