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 $
|
|
|
|