This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
The pool will only manage instances that were explicitly passed into the pool before. For more sophisticated pooling strategies, derive from this class or wrap it.
The implementation will provide these instances wrapped by a proxy, that will return the instance automatically to the pool, if it falls out of scope and is collected by the garbage collector. Since the pool only returns instances wrapped by a proxy that implements the {@link Poolable} interface, this can be used to release th instance manuallyto the pool also. With an implementation of the {@link Resetter} interface each element's status can be reset or theelement can be dropped from the pool at all, if it is exhausted.
A client can use the pool's monitor for an improved synchronization. Everytime an object is returned to the pool, all waiting Threads of the monitor will be notified. This notification will happen independently of the result of the {@link Resetter#reset(Object)} method.
@author Jörg Schaible @since 0.2 @see com.thoughtworks.proxy.toys.poolPool
that caches Poolable objects for reuse.
@author Avalon Development Team
@version CVS $Revision: 1.6 $ $Date: 2004/03/29 16:50:37 $
@since 4.0
Unlike traditional Pools, this class does not create new instances of the objects it stores (with the exception of simple Java Beans, via {@link #retrieve(Class)}. The usage pattern is to retrieve an instance from the Pool, and if the instance is null, create a new instance.
The implementation of Pool is threadsafe.
Pool implements {@link ICleanable}, with a goal of only keeping pooled objects that have been needed within a recent time frame. A generational system is used, where each pooled object is assigned a generation count. {@link #executeCleanup}discards objects whose generation count is too old (outside of a {@link #getWindow() window}).
Objects in the pool can receive two notifications: one notification when they are {@link #store(Object,Object) stored} into the pool,and one when they are discarded from the pool.
Classes that implement {@link org.apache.tapestry.util.pool.IPoolable}receive notifications directly, as per the two methods of that interface.
Alternately, an adaptor for the other classes can be registerered (using {@link #registerAdaptor(Class,IPoolableAdaptor)}. The adaptor will be invoked to handle the notification when a pooled object is stored or discarded. @author Howard Lewis Ship @version $Id: Pool.java 243791 2004-02-19 17:38:13Z hlship $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|