KeyedObjectPool implementation. When coupled with the appropriate {@link KeyedPoolableObjectFactory}, GenericKeyedObjectPool provides robust pooling functionality for keyed objects. A GenericKeyedObjectPool can be viewed as a map of 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 new pool is created under the given key to be managed by the containing GenericKeyedObjectPool.
A GenericKeyedObjectPool provides a number of configurable parameters:
maxTotal is set to a positive value and {@link #borrowObject borrowObject} is invokedwhen at the limit with no idle instances available, an attempt is made to create room by clearing the oldest 15% of the elements from the keyed pools. The default setting for this parameter is -1 (no limit). whenExhaustedAction setting is {@link #WHEN_EXHAUSTED_BLOCK}. false. false. 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 require an exclusive synchronization lock on the pool, so if they run too frequently and / or incur excessive latency when creating, destroying or validating object instances, performance issues may result. The idle object eviction thread may be configured using the following attributes:
timeBetweenEvictionRunsMillis > 0. The default setting for this parameter is 30 minutes. timeBetweenEvictionRunsMillis > 0. The default setting for this parameter is false. timeBetweenEvictionRunsMillis > 0, each time the idle object eviction thread runs, it will try to create enough idle instances so that there will be minIdle idle instances available under each key. This parameter is also used by {@link #preparePool preparePool}if true is provided as that method's populateImmediately parameter. The default setting for this parameter is 0. The pools can be configured to behave as LIFO queues with respect to idle objects - always returning the most recently used object from the pool, or as FIFO queues, where borrowObject always returns the oldest object in the idle object pool.
true. GenericKeyedObjectPool is not usable without a {@link KeyedPoolableObjectFactory}. A non-null factory must be provided either as a constructor argument or via a call to {@link #setFactory setFactory} before the pool is used.
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.
@see GenericObjectPool @author Rodney Waldhoff @author Dirk Verbeeck @author Sandy McArthur @version $Revision: 784441 $ $Date: 2009-06-13 13:42:28 -0400 (Sat, 13 Jun 2009) $ @since Pool 1.0 | |
| |
| |
| |
| |
| |
| |
| |
| |
| |