KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > smartlib > pool > core > Pool


1 /*
2  * @(#) Pool 1.0 02/08/01
3  */

4
5 package org.smartlib.pool.core;
6
7 import java.sql.Connection JavaDoc;
8 import java.util.*;
9
10 /**
11  * This interface defines the behavior of the class that will manage the
12  * connections i.e a single pool of connections.
13  */

14
15 public interface Pool {
16
17     
18     /**
19      * This method returns a Connection from the connection pool.
20      * The owner of this pool is marked as N/A indicating unknown.
21      *
22      * <b>Note: This method blocks if the pool size has reached it's
23      * maximum size and no free connections are available
24      * until a free connection is available</b>. The time period for which this
25      * method blocks depends on the connection-wait-time-out specified in
26      * the configuration file.
27      *
28      *
29      * @return Connection from the pool
30      * @exception ConnectionPoolException if there is any problem
31      * getting connection.
32      */

33     public Connection JavaDoc getConnection()
34         throws ConnectionPoolException;
35
36
37     /**
38      * This method returns a Connection from the pool.
39      * The owner of this connection is identified by <code>owner</code> .
40      *
41      * <b>Note: This method blocks if the pool size has reached it's
42      * maximum size and no free connections are available
43      * until a free connection is available</b>. The time period for which this
44      * method blocks depends on the connection-wait-time-out specified in
45      * the configuration file.
46      *
47      *
48      * @param owner String identifying the owner.
49      * @return Connection from the pool
50      *
51      * @exception ConnectionPoolException if there is any problem
52      * getting connection.
53      */

54     
55     public Connection JavaDoc getConnection(String JavaDoc owner)
56         throws ConnectionPoolException;
57
58     /**
59      * This method returns the current size of the pool.
60      * @return Current size of the pool
61      */

62     public int getCurrentPoolSize();
63
64     /**
65      * This method releases the Connection <code>conn</code> to the pool.
66      */

67     public void returnConnection(Connection JavaDoc conn);
68
69     /**
70      * @return Vector of connections in use
71      */

72     public Vector getConnectionsInUse();
73     
74     /**
75      * @return Vector of registered ConnectionLeakListeners
76      */

77     public Vector getConnectionLeakListeners();
78
79     /**
80      * @return Number of free connections in the pool.
81      */

82     public int getNoOfFreeConnections();
83
84     /**
85      * This method adds a connection leak listener. The methods of
86      * <code>cle</code> will be called when a leak is detected as per the
87      * pool configuration.
88      *
89      * @param cle Class implementing ConnectionLeakListener interface.
90      * @exception ConnectionPoolException If there is any problem
91      * adding ConnectionLeakListener.
92      */

93     public void addConnectionLeakListener(ConnectionLeakListener cle )
94         throws ConnectionPoolException;
95
96     /**
97      * This method removes a connection leak listener.<code>cle</code> will
98      * not get any further notifications.
99      *
100      * @param cle Class implementing ConnectionLeakListener interface.
101      * @exception ConnectionPoolException If there is any problem
102      * removing ConnectionLeakListener.
103      */

104     public void removeConnectionLeakListener(ConnectionLeakListener cle)
105         throws ConnectionPoolException;
106
107     /**
108      * This method releases excessive connections.
109      */

110     public void releaseConnections() ;
111
112     /**
113      * This method shuts down the pool
114      */

115     public void shutDown();
116
117 }
118
Popular Tags