connectionpool
Class ConnectionPool

java.lang.Object
  |
  +--connectionpool.ConnectionPool

public class ConnectionPool
extends java.lang.Object
implements Pool, PoolMonitor

This class implements the Pool interface and thus is responsible for managing a single pool of connections.


Method Summary
 void addConnectionLeakListener(ConnectionLeakListener cle)
          This method adds a connection leak listener.
protected  void finalize()
           
 ConfigMonitor getConfigMonitor()
          This method returns an instance of ConfigMonitor.
 java.sql.Connection getConnection()
          This method returns a Connection from the connection pool.
 java.sql.Connection getConnection(java.lang.String owner)
          This method returns a Connection from the pool.
 java.util.Vector getConnectionLeakListeners()
           
 java.util.Vector getConnectionsInUse()
           
 int getCurrentPoolSize()
          This method returns the current size of the pool.
 int getNoOfFreeConnections()
           
 void releaseConnections()
          This method releases excessive connections, i.e it actully closes them.
 void removeConnectionLeakListener(ConnectionLeakListener cle)
          This method removes a connection leak listener.
 void returnConnection(java.sql.Connection ret)
          This method releases the connection back to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getConnectionsInUse

public java.util.Vector getConnectionsInUse()
Specified by:
getConnectionsInUse in interface Pool
Returns:
Vector of connections in use.

getConnectionLeakListeners

public java.util.Vector getConnectionLeakListeners()
Specified by:
getConnectionLeakListeners in interface Pool
Returns:
Vector of registered ConnectionLeakListeners.

getNoOfFreeConnections

public int getNoOfFreeConnections()
Specified by:
getNoOfFreeConnections in interface Pool
Returns:
Number of free connections in the pool.

getConfigMonitor

public ConfigMonitor getConfigMonitor()
This method returns an instance of ConfigMonitor.
Specified by:
getConfigMonitor in interface PoolMonitor
Returns:
ConfigMonitor for monitoring the configuration of the pool at runtime.

getCurrentPoolSize

public int getCurrentPoolSize()
This method returns the current size of the pool.
Specified by:
getCurrentPoolSize in interface Pool
Returns:
Current size of the pool.

getConnection

public java.sql.Connection getConnection()
                                  throws ConnectionPoolException
This method returns a Connection from the connection pool. The owner of this pool is marked as N/A indicating unknown/anonymous. Note: This method blocks if the pool size has reached it's maximum size and no free connections are available until a free connection is available. The time period for which this method blocks depends on the connection-wait-time-out specified in the configuration file.
Specified by:
getConnection in interface Pool
Returns:
Connection from the pool.
Throws:
ConnectionPoolException - if there is any problem getting connection.

getConnection

public java.sql.Connection getConnection(java.lang.String owner)
                                  throws ConnectionPoolException
This method returns a Connection from the pool. The owner of this connection is identified by owner . Note: This method blocks if the pool size has reached it's maximum size and no free connections are available until a free connection is available. The time period for which this method blocks depends on the connection-wait-time-out specified in the configuration file.
Specified by:
getConnection in interface Pool
Parameters:
owner - String identifying the owner.
Returns:
Connection from the pool
Throws:
ConnectionPoolException - if there is any problem getting connection.

returnConnection

public void returnConnection(java.sql.Connection ret)
This method releases the connection back to the pool.
Specified by:
returnConnection in interface Pool
Parameters:
ret - connection to be released

addConnectionLeakListener

public void addConnectionLeakListener(ConnectionLeakListener cle)
                               throws ConnectionPoolException
This method adds a connection leak listener. The methods of cle will be called when a leak is detected as per the pool configuration.
Specified by:
addConnectionLeakListener in interface Pool
Parameters:
cle - Class implementing ConnectionLeakListener interface.
Throws:
ConnectionPoolException - if there is any problem adding ConnectionLeakListener.

removeConnectionLeakListener

public void removeConnectionLeakListener(ConnectionLeakListener cle)
                                  throws ConnectionPoolException
This method removes a connection leak listener. cle will not get any further notifications.
Specified by:
removeConnectionLeakListener in interface Pool
Parameters:
cle - Class implementing ConnectionLeakListener interface.
Throws:
ConnectionPoolException - If there is any problem removing ConnectionLeakListener.

releaseConnections

public void releaseConnections()
This method releases excessive connections, i.e it actully closes them.
Specified by:
releaseConnections in interface Pool

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object