Package org.apache.commons.pool.impl
Class GenericKeyedObjectPoolFactory<K,V>
- java.lang.Object
-
- org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory<K,V>
-
- Type Parameters:
K- the type of keys in this poolV- the type of objects held in this pool
- All Implemented Interfaces:
KeyedObjectPoolFactory<K,V>
public class GenericKeyedObjectPoolFactory<K,V> extends java.lang.Object implements KeyedObjectPoolFactory<K,V>
A factory for creatingGenericKeyedObjectPoolinstances.- Since:
- Pool 1.0
- Version:
- $Revision: 1222396 $ $Date: 2011-12-22 14:02:25 -0500 (Thu, 22 Dec 2011) $
- See Also:
GenericKeyedObjectPool,KeyedObjectPoolFactory
-
-
Field Summary
Fields Modifier and Type Field Description protected KeyedPoolableObjectFactory<K,V>_factoryDeprecated.to be removed in pool 2.0.protected boolean_lifoDeprecated.to be removed in pool 2.0.protected int_maxActiveDeprecated.to be removed in pool 2.0.protected int_maxIdleDeprecated.to be removed in pool 2.0.protected int_maxTotalDeprecated.to be removed in pool 2.0.protected long_maxWaitDeprecated.to be removed in pool 2.0.protected long_minEvictableIdleTimeMillisDeprecated.to be removed in pool 2.0.protected int_minIdleDeprecated.to be removed in pool 2.0.protected int_numTestsPerEvictionRunDeprecated.to be removed in pool 2.0.protected boolean_testOnBorrowDeprecated.to be removed in pool 2.0.protected boolean_testOnReturnDeprecated.to be removed in pool 2.0.protected boolean_testWhileIdleDeprecated.to be removed in pool 2.0.protected long_timeBetweenEvictionRunsMillisDeprecated.to be removed in pool 2.0.protected byte_whenExhaustedActionDeprecated.to be removed in pool 2.0.
-
Constructor Summary
Constructors Constructor Description GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, boolean testOnBorrow, boolean testOnReturn)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle, boolean lifo)Create a new GenericKeyedObjectPoolFactory.GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, GenericKeyedObjectPool.Config config)Create a new GenericKeyedObjectPoolFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyedObjectPool<K,V>createPool()Create a new GenericKeyedObjectPool with the currently configured properties.KeyedPoolableObjectFactory<K,V>getFactory()booleangetLifo()intgetMaxActive()intgetMaxIdle()intgetMaxTotal()longgetMaxWait()longgetMinEvictableIdleTimeMillis()intgetMinIdle()intgetNumTestsPerEvictionRun()booleangetTestOnBorrow()booleangetTestOnReturn()booleangetTestWhileIdle()longgetTimeBetweenEvictionRunsMillis()bytegetWhenExhaustedAction()
-
-
-
Field Detail
-
_maxIdle
@Deprecated protected int _maxIdle
Deprecated.to be removed in pool 2.0. UsegetMaxIdle().ThemaxIdlesetting for pools created by this factory.
-
_maxActive
@Deprecated protected int _maxActive
Deprecated.to be removed in pool 2.0. UsegetMaxActive().ThemaxActivesetting for pools created by this factory.
-
_maxTotal
@Deprecated protected int _maxTotal
Deprecated.to be removed in pool 2.0. UsegetMaxTotal().ThemaxTotalsetting for pools created by this factory.
-
_minIdle
@Deprecated protected int _minIdle
Deprecated.to be removed in pool 2.0. UsegetMinIdle().TheminIdlesetting for pools created by this factory.
-
_maxWait
@Deprecated protected long _maxWait
Deprecated.to be removed in pool 2.0. UsegetMaxWait().ThemaxWaitsetting for pools created by this factory.
-
_whenExhaustedAction
@Deprecated protected byte _whenExhaustedAction
Deprecated.to be removed in pool 2.0. UsegetWhenExhaustedAction().ThewhenExhaustedActionsetting for pools created by this factory.
-
_testOnBorrow
@Deprecated protected boolean _testOnBorrow
Deprecated.to be removed in pool 2.0. UsegetTestOnBorrow().ThetestOnBorrowsetting for pools created by this factory.
-
_testOnReturn
@Deprecated protected boolean _testOnReturn
Deprecated.to be removed in pool 2.0. UsegetTestOnReturn().ThetestOnReturnsetting for pools created by this factory.
-
_testWhileIdle
@Deprecated protected boolean _testWhileIdle
Deprecated.to be removed in pool 2.0. UsegetTestWhileIdle().ThetestWhileIdlesetting for pools created by this factory.
-
_timeBetweenEvictionRunsMillis
@Deprecated protected long _timeBetweenEvictionRunsMillis
Deprecated.to be removed in pool 2.0. UsegetTimeBetweenEvictionRunsMillis().ThetimeBetweenEvictionRunsMillissetting for pools created by this factory.
-
_numTestsPerEvictionRun
@Deprecated protected int _numTestsPerEvictionRun
Deprecated.to be removed in pool 2.0. UsegetNumTestsPerEvictionRun().ThenumTestsPerEvictionRunsetting for pools created by this factory.
-
_minEvictableIdleTimeMillis
@Deprecated protected long _minEvictableIdleTimeMillis
Deprecated.to be removed in pool 2.0. UsegetMinEvictableIdleTimeMillis().TheminEvictableIdleTimeMillissetting for pools created by this factory.
-
_factory
@Deprecated protected KeyedPoolableObjectFactory<K,V> _factory
Deprecated.to be removed in pool 2.0. UsegetFactory().TheKeyedPoolableObjectFactoryused by pools created by this factory.
-
-
Constructor Detail
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, GenericKeyedObjectPool.Config config) throws java.lang.NullPointerException
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.config- a non-null GenericKeyedObjectPool.Config describing the configuration.- Throws:
java.lang.NullPointerException- when config isnull.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, GenericKeyedObjectPool.Config)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, boolean testOnBorrow, boolean testOnReturn)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.testOnBorrow- whether to validate objects before they are returned by borrowObject.testOnReturn- whether to validate objects after they are returned to returnObject.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, boolean, boolean)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.maxIdle- the maximum number of idle objects in the pools.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.maxIdle- the maximum number of idle objects in the pools.maxTotal- the maximum number of objects that can exists at one time.
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.maxIdle- the maximum number of idle objects in the pools.testOnBorrow- whether to validate objects before they are returned by borrowObject.testOnReturn- whether to validate objects after they are returned to returnObject.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, boolean, boolean)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.maxIdle- the maximum number of idle objects in the pools.testOnBorrow- whether to validate objects before they are returned by borrowObject.testOnReturn- whether to validate objects after they are returned to returnObject.timeBetweenEvictionRunsMillis- the number of milliseconds to sleep between examining idle objects for eviction.numTestsPerEvictionRun- the number of idle objects to examine per run of the evictor.minEvictableIdleTimeMillis- the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.testWhileIdle- whether to validate objects in the idle object eviction thread.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, boolean, boolean, long, int, long, boolean)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.maxIdle- the maximum number of idle objects in the pools.maxTotal- the maximum number of objects that can exists at one time.testOnBorrow- whether to validate objects before they are returned by borrowObject.testOnReturn- whether to validate objects after they are returned to returnObject.timeBetweenEvictionRunsMillis- the number of milliseconds to sleep between examining idle objects for eviction.numTestsPerEvictionRun- the number of idle objects to examine per run of the evictor.minEvictableIdleTimeMillis- the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.testWhileIdle- whether to validate objects in the idle object eviction thread.- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, boolean, boolean, long, int, long, boolean)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.maxIdle- the maximum number of idle objects in the pools.maxTotal- the maximum number of objects that can exists at one time.minIdle- the minimum number of idle objects to have in the pool at any one time.testOnBorrow- whether to validate objects before they are returned by borrowObject.testOnReturn- whether to validate objects after they are returned to returnObject.timeBetweenEvictionRunsMillis- the number of milliseconds to sleep between examining idle objects for eviction.numTestsPerEvictionRun- the number of idle objects to examine per run of the evictor.minEvictableIdleTimeMillis- the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.testWhileIdle- whether to validate objects in the idle object eviction thread.- Since:
- Pool 1.3
- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, int, boolean, boolean, long, int, long, boolean)
-
GenericKeyedObjectPoolFactory
public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle, boolean lifo)
Create a new GenericKeyedObjectPoolFactory.- Parameters:
factory- the KeyedPoolableObjectFactory to used by created pools.maxActive- the maximum number of objects that can be borrowed from pools at one time.whenExhaustedAction- the action to take when the pool is exhausted.maxWait- the maximum amount of time to wait for an idle object when the pool is exhausted.maxIdle- the maximum number of idle objects in the pools.maxTotal- the maximum number of objects that can exists at one time.minIdle- the minimum number of idle objects to have in the pool at any one time.testOnBorrow- whether to validate objects before they are returned by borrowObject.testOnReturn- whether to validate objects after they are returned to returnObject.timeBetweenEvictionRunsMillis- the number of milliseconds to sleep between examining idle objects for eviction.numTestsPerEvictionRun- the number of idle objects to examine per run of the evictor.minEvictableIdleTimeMillis- the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.testWhileIdle- whether to validate objects in the idle object eviction thread.lifo- whether or not objects are returned in last-in-first-out order from the idle object pool.- Since:
- Pool 1.4
- See Also:
GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, int, boolean, boolean, long, int, long, boolean, boolean)
-
-
Method Detail
-
createPool
public KeyedObjectPool<K,V> createPool()
Create a new GenericKeyedObjectPool with the currently configured properties.- Specified by:
createPoolin interfaceKeyedObjectPoolFactory<K,V>- Returns:
- GenericKeyedObjectPool with
Configurationdetermined by current property settings
-
getMaxIdle
public int getMaxIdle()
- Returns:
- the
maxIdlesetting for pools created by this factory. - Since:
- 1.5.5
-
getMaxActive
public int getMaxActive()
- Returns:
- the
maxActivesetting for pools created by this factory. - Since:
- 1.5.5
-
getMaxTotal
public int getMaxTotal()
- Returns:
- the
maxTotalsetting for pools created by this factory. - Since:
- 1.5.5
-
getMinIdle
public int getMinIdle()
- Returns:
- the
minIdlesetting for pools created by this factory. - Since:
- 1.5.5
-
getMaxWait
public long getMaxWait()
- Returns:
- the
maxWaitsetting for pools created by this factory. - Since:
- 1.5.5
-
getWhenExhaustedAction
public byte getWhenExhaustedAction()
- Returns:
- the
whenExhaustedActionsetting for pools created by this factory. - Since:
- 1.5.5
-
getTestOnBorrow
public boolean getTestOnBorrow()
- Returns:
- the
testOnBorrowsetting for pools created by this factory. - Since:
- 1.5.5
-
getTestOnReturn
public boolean getTestOnReturn()
- Returns:
- the
testOnReturnsetting for pools created by this factory. - Since:
- 1.5.5
-
getTestWhileIdle
public boolean getTestWhileIdle()
- Returns:
- the
testWhileIdlesetting for pools created by this factory. - Since:
- 1.5.5
-
getTimeBetweenEvictionRunsMillis
public long getTimeBetweenEvictionRunsMillis()
- Returns:
- the
timeBetweenEvictionRunsMillissetting for pools created by this factory. - Since:
- 1.5.5
-
getNumTestsPerEvictionRun
public int getNumTestsPerEvictionRun()
- Returns:
- the
numTestsPerEvictionRunsetting for pools created by this factory. - Since:
- 1.5.5
-
getMinEvictableIdleTimeMillis
public long getMinEvictableIdleTimeMillis()
- Returns:
- the
minEvictableIdleTimeMillissetting for pools created by this factory. - Since:
- 1.5.5
-
getFactory
public KeyedPoolableObjectFactory<K,V> getFactory()
- Returns:
- the
KeyedPoolableObjectFactoryused by pools created by this factory. - Since:
- 1.5.5
-
getLifo
public boolean getLifo()
- Returns:
- the
lifosetting for pools created by this factory. - Since:
- 1.5.5
-
-