001: /*
002: * @(#) Pool 1.0 02/08/01
003: */
004:
005: package org.smartlib.pool.core;
006:
007: import java.sql.Connection;
008: import java.util.*;
009:
010: /**
011: * This interface defines the behavior of the class that will manage the
012: * connections i.e a single pool of connections.
013: */
014:
015: public interface Pool {
016:
017: /**
018: * This method returns a Connection from the connection pool.
019: * The owner of this pool is marked as N/A indicating unknown.
020: *
021: * <b>Note: This method blocks if the pool size has reached it's
022: * maximum size and no free connections are available
023: * until a free connection is available</b>. The time period for which this
024: * method blocks depends on the connection-wait-time-out specified in
025: * the configuration file.
026: *
027: *
028: * @return Connection from the pool
029: * @exception ConnectionPoolException if there is any problem
030: * getting connection.
031: */
032: public Connection getConnection() throws ConnectionPoolException;
033:
034: /**
035: * This method returns a Connection from the pool.
036: * The owner of this connection is identified by <code>owner</code> .
037: *
038: * <b>Note: This method blocks if the pool size has reached it's
039: * maximum size and no free connections are available
040: * until a free connection is available</b>. The time period for which this
041: * method blocks depends on the connection-wait-time-out specified in
042: * the configuration file.
043: *
044: *
045: * @param owner String identifying the owner.
046: * @return Connection from the pool
047: *
048: * @exception ConnectionPoolException if there is any problem
049: * getting connection.
050: */
051:
052: public Connection getConnection(String owner)
053: throws ConnectionPoolException;
054:
055: /**
056: * This method returns the current size of the pool.
057: * @return Current size of the pool
058: */
059: public int getCurrentPoolSize();
060:
061: /**
062: * This method releases the Connection <code>conn</code> to the pool.
063: */
064: public void returnConnection(Connection conn);
065:
066: /**
067: * @return Vector of connections in use
068: */
069: public Vector getConnectionsInUse();
070:
071: /**
072: * @return Vector of registered ConnectionLeakListeners
073: */
074: public Vector getConnectionLeakListeners();
075:
076: /**
077: * @return Number of free connections in the pool.
078: */
079: public int getNoOfFreeConnections();
080:
081: /**
082: * This method adds a connection leak listener. The methods of
083: * <code>cle</code> will be called when a leak is detected as per the
084: * pool configuration.
085: *
086: * @param cle Class implementing ConnectionLeakListener interface.
087: * @exception ConnectionPoolException If there is any problem
088: * adding ConnectionLeakListener.
089: */
090: public void addConnectionLeakListener(ConnectionLeakListener cle)
091: throws ConnectionPoolException;
092:
093: /**
094: * This method removes a connection leak listener.<code>cle</code> will
095: * not get any further notifications.
096: *
097: * @param cle Class implementing ConnectionLeakListener interface.
098: * @exception ConnectionPoolException If there is any problem
099: * removing ConnectionLeakListener.
100: */
101: public void removeConnectionLeakListener(ConnectionLeakListener cle)
102: throws ConnectionPoolException;
103:
104: /**
105: * This method releases excessive connections.
106: */
107: public void releaseConnections();
108:
109: /**
110: * This method shuts down the pool
111: */
112: public void shutDown();
113:
114: }
|