The Pool package makes it possible separate the way in which instances
are pooled from the way in which instances are created and destroyed.
PoolableObjectFactory
supports this by providing a generic inteface for the lifecycle of a pooled object:
public interface PoolableObjectFactory {
Object makeObject();
void activateObject(Object obj);
void passivateObject(Object obj);
boolean validateObject(Object obj);
void destroyObject(Object obj);
}
ObjectPool
implementations may be written to accept arbitrary
PoolableObjectFactory
s.
This makes is possible for clients to select pooling-behavior distinct
from the kinds of objects that are pooled.
BasePoolableObjectFactory
provides an abstract base implementation of PoolableObjectFactory
that
makes implementations a snap.
KeyedPoolableObjectFactory
defines a similiar interface for KeyedObjectPool
s:
public interface KeyedPoolableObjectFactory {
Object makeObject(Object key);
void activateObject(Object key, Object obj);
void passivateObject(Object key, Object obj);
boolean validateObject(Object key, Object obj);
void destroyObject(Object key, Object obj);
}
BaseKeyedPoolableObjectFactory
provides an abstract base implementation of KeyedPoolableObjectFactory
that
makes implementations a snap.