A configurable
KeyedObjectPool
implementation.
When coupled with the appropriate {@link KeyedPooledObjectFactory}, GenericKeyedObjectPool
provides robust pooling functionality for keyed objects. A GenericKeyedObjectPool
can be viewed as a map of sub-pools, keyed on the (unique) key values provided to the {@link #preparePool preparePool}, {@link #addObject addObject} or{@link #borrowObject borrowObject} methods. Each time a new key value isprovided to one of these methods, a sub-new pool is created under the given key to be managed by the containing GenericKeyedObjectPool.
Optionally, one may configure the pool to examine and possibly evict objects as they sit idle in the pool and to ensure that a minimum number of idle objects is maintained for each key. This is performed by an "idle object eviction" thread, which runs asynchronously. Caution should be used when configuring this optional feature. Eviction runs contend with client threads for access to objects in the pool, so if they run too frequently performance issues may result.
Implementation note: To prevent possible deadlocks, care has been taken to ensure that no call to a factory method will occur within a synchronization block. See POOL-125 and DBCP-44 for more information.
This class is intended to be thread-safe.
@see GenericObjectPool
@param < K> The type of keys maintained by this pool.
@param < T> Type of element pooled in this pool.
@since 2.0