|
|||||||||||
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. |
java.lang.Object |
newInstance()
Create a new instance of the object being pooled. |
void |
release(java.lang.Object pooledObject)
Release the instance of the pooled object. |
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 java.lang.Object newInstance() throws java.lang.Exception
java.lang.Exception
- if the instance cannot be created
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |