When coupled with the appropriate {@link PoolableObjectFactory}, GenericObjectPool provides robust pooling functionality for arbitrary objects.
A GenericObjectPool provides a number of configurable parameters:
whenExhaustedAction
setting is {@link #WHEN_EXHAUSTED_BLOCK} and the default maxWait
setting is -1. By default, therefore, borrowObject
will block indefinitely until an idle instance becomes available. 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 are available. 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. 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.
and it is superceded by {@link #setMinEvictableIdleTimeMillis minEvictableIdleTimeMillis}(that is, if minEvictableIdleTimeMillis
is positive, then softMinEvictableIdleTimeMillis
is ignored). The default setting for this parameter is -1 (disabled). timeBetweenEvictionRunsMillis > 0.
The default setting for this parameter is 3.
The pool can be configured to behave as a LIFO queue with respect to idle objects - always returning the most recently used object from the pool, or as a FIFO queue, where borrowObject always returns the oldest object in the idle object pool.
true.
GenericObjectPool is not usable without a {@link PoolableObjectFactory}. A non-null
factory must be provided either as a constructor argument or via a call to {@link #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 GenericKeyedObjectPool @author Rodney Waldhoff @author Dirk Verbeeck @author Sandy McArthur @version $Revision: 952050 $ $Date: 2010-06-06 21:15:50 -0400 (Sun, 06 Jun 2010) $ @since Pool 1.0
|
|
|
|
|
|