|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface is to define how a Pool is used. We have determined by using the previous Pool implementations that the Pool marker interface is considered harmful. When generics are introduced in JDK 1.5, this interface will be a prime candidate for those improvements.
It is important to realize that some objects are cheaper to simply allow the garbage collector to take care of them. Therefore, only pool objects that are computationally expensive to create. Prime candidates would be Components, JDBC Connection objects, Socket connections, etc. The interface is inspired by both the Mutex acquire/release and the structure of the ThreadLocal object. In fact, it would be trivial to implement a "ThreadLocal" pool.
Method Summary | |
java.lang.Object |
acquire()
Acquire an instance of the pooled object. |
void |
addPoolListener(PoolListener listener)
Add a pool listener to the pool. |
void |
release(java.lang.Object pooledObject)
Release the instance of the pooled object. |
void |
removePoolListener(PoolListener listener)
Remove a pool listener from the pool. |
Method Detail |
public java.lang.Object acquire() throws java.lang.Exception
java.lang.Exception
- if the Pool is not able to return an object.public void release(java.lang.Object pooledObject)
pooledObject
- The pooled object to release to the pool.public void addPoolListener(PoolListener listener)
listener
- the listener to add.public void removePoolListener(PoolListener listener)
listener
- the listener to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |