public class ConnectionPool
extends java.lang.Object
When a client does a look up for a connection against the Connection Architecture The Factory that is resposible for creating the connection instances first checks the pool to see if the requested connection already exists. If yes the connection is recycled from the pool
In any case the client is always guarenteed to have a unique instance of the a connection. The instance could be a recycled instance from a pool or a new instance. This is opaque to the client
Constructor and Description |
---|
ConnectionPool()
Create a ConnectionPool instance of a default size
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
allocate(java.lang.Object poolKey)
Allocate a connection instance from this pool.
|
protected void |
clearCache(java.lang.Object poolKey)
This is an expensive operation and should be called ONLY when the
connection instance is removed from the Context.
|
void |
put(java.lang.Object poolKey,
java.lang.Object connection,
boolean used)
Put an Object into the Pool for the first time so that
it can be allocated and recycled for subsequent client
requests.
|
void |
release(java.lang.Object connection)
Release a connection back to the pool
|
protected void |
removeBinding(java.lang.Object poolKey,
java.lang.Object connection)
Removes an object from pool, instead of freeing it.
|
public ConnectionPool()
public void put(java.lang.Object poolKey, java.lang.Object connection, boolean used) throws java.lang.Exception
poolKey
- The Key associated with the connection instanceconnection
- The Connection instance to be added to the pool.Exception
- If the connection could be added to
the pool.java.lang.Exception
public java.lang.Object allocate(java.lang.Object poolKey) throws java.lang.Exception
poolKey
- The Key associated with the connection to be allocated.java.lang.Exception
public void release(java.lang.Object connection) throws java.lang.Exception
connection
- The connection instance to be released back to the pool.java.lang.Exception
protected void removeBinding(java.lang.Object poolKey, java.lang.Object connection)
poolKey
- the key with which connection was added to poolprotected void clearCache(java.lang.Object poolKey)