com.cafesoft.core.jdbc
Class StandardConnectionPool

java.lang.Object
  |
  +--com.cafesoft.core.jdbc.StandardConnectionPool
All Implemented Interfaces:
ConnectionPool, Debuggable, LoggerClient

public class StandardConnectionPool
extends Object
implements ConnectionPool

Standard implementation of the ConnectionPool interface

Since:
11/1/02
See Also:
ConnectionPool

Method Summary
 void close()
          Close the ConnectionPool
 void destroy()
          Destroy the ConnectionPool
 ConnectionPoolAuthenticator getAuthenticator()
          Get the ConnectionPool's ConnectionPoolAuthenticator
 Connection getConnection()
          Get a Connection from the Pool
 ConnectionPoolInfo getInfo()
          Get information about the ConnectionPool Object
static ConnectionPool getInstance(ConnectionPoolConfig poolConfig)
          Static constructor This constructor invokes the private constructor and then invokes the private initialize method.
 void refreshConnections()
          Refresh all inactive Connections in the ConnectionPool
 void returnConnection(Connection c)
          Return a Connection to the Pool
 void setAuthenticator(ConnectionPoolAuthenticator authenticator)
          Set the ConnectionPoolAuthenticator for this ConnectionPool
 boolean setDebug(boolean enable)
          Enable or disable debugging.
 void setLogger(Logger logger)
          Sets the logger.
 void shrinkConnections()
          Shrink inactive Connections This method will destroy any inactive Connection that is above the ConnectionPool's minimum number of connection value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ConnectionPool getInstance(ConnectionPoolConfig poolConfig)
                                  throws ConnectionPoolException
Static constructor

This constructor invokes the private constructor and then invokes the private initialize method. The result is a ConnectionPool that has it's minimum number of connections created and is ready to be used.

Parameters:
poolConfig - the ConnectionPool configuration object
Returns:
a new ConnectionPool that is initialized and ready to be used.
Throws:
ConnectionPoolException

setLogger

public void setLogger(Logger logger)
Sets the logger.

Specified by:
setLogger in interface LoggerClient
Parameters:
logger - logs messages

setDebug

public boolean setDebug(boolean enable)
Enable or disable debugging.

Specified by:
setDebug in interface Debuggable
Parameters:
enable - if true, enable debugging, else disable debugging.
Returns:
the previous value of the debug flag, which is useful for restoring the debug state if temporarily changed.

getInfo

public ConnectionPoolInfo getInfo()
Get information about the ConnectionPool Object

Specified by:
getInfo in interface ConnectionPool
Returns:
a ConnectionPoolInfo object which contains the current state of the ConnectionPool Object

setAuthenticator

public void setAuthenticator(ConnectionPoolAuthenticator authenticator)
Set the ConnectionPoolAuthenticator for this ConnectionPool

Specified by:
setAuthenticator in interface ConnectionPool
Parameters:
authenticator - the new ConnectionPoolAuthenticator

getAuthenticator

public ConnectionPoolAuthenticator getAuthenticator()
Get the ConnectionPool's ConnectionPoolAuthenticator

Specified by:
getAuthenticator in interface ConnectionPool
Returns:
the ConnectionPoolAuthenticator

getConnection

public Connection getConnection()
                         throws ConnectionPoolException
Get a Connection from the Pool

Specified by:
getConnection in interface ConnectionPool
Returns:
a valid Connection Object that is ready to be used by the application retrieving the Connection object
Throws:
ConnectionPoolException - thrown if the ConnectionPool is at it's maximum or if the pool has closed

returnConnection

public void returnConnection(Connection c)
Return a Connection to the Pool

Specified by:
returnConnection in interface ConnectionPool
Parameters:
c - the Connection to return, if c is null the method simply returns

shrinkConnections

public void shrinkConnections()
                       throws ConnectionPoolException
Shrink inactive Connections

This method will destroy any inactive Connection that is above the ConnectionPool's minimum number of connection value

Specified by:
shrinkConnections in interface ConnectionPool
Throws:
ConnectionPoolException - thrown if an error occurs shrinking the Connections

refreshConnections

public void refreshConnections()
                        throws ConnectionPoolException
Refresh all inactive Connections in the ConnectionPool

Specified by:
refreshConnections in interface ConnectionPool
Throws:
ConnectionPoolException - thrown if an error occurs refreshing the Connections

close

public void close()
Close the ConnectionPool

Specified by:
close in interface ConnectionPool

destroy

public void destroy()
Destroy the ConnectionPool

Specified by:
destroy in interface ConnectionPool


Generated on 5:16:42 PM May 12, 2008, © 1996-2005 Cafésoft LLC. All rights reserved.