类 CommonsPool2TargetSource
- 所有已实现的接口:
PoolingConfig,TargetClassAware,TargetSource,infra.beans.factory.Aware,infra.beans.factory.BeanFactoryAware,infra.beans.factory.DisposableBean,Serializable,org.apache.commons.pool2.PooledObjectFactory<Object>
TargetSource implementation that holds objects in a
configurable Apache Commons2 Pool.
By default, an instance of GenericObjectPool is created.
Subclasses may change the type of ObjectPool used by
overriding the createObjectPool() method.
Provides many configuration properties mirroring those of the Commons Pool
GenericObjectPool class; these properties are passed to the
GenericObjectPool during construction. If creating a subclass of this
class to change the ObjectPool implementation type, pass in the values
of configuration properties that are relevant to your chosen implementation.
The testOnBorrow, testOnReturn and testWhileIdle
properties are explicitly not mirrored because the implementation of
PoolableObjectFactory used by this class does not implement
meaningful validation. All exposed Commons Pool properties use the
corresponding Commons Pool defaults.
Compatible with Apache Commons Pool 2.4
- 从以下版本开始:
- 4.0 2021/12/13 22:33
- 作者:
- Rod Johnson, Rob Harrop, Juergen Hoeller, Stephane Nicoll, Kazuki Shimizu, Harry Yang
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private booleanprivate intprivate longprivate longprivate intprivate org.apache.commons.pool2.ObjectPoolThe Apache CommonsObjectPoolused to pool target objects.private static final longprivate long从类继承的字段 infra.aop.target.AbstractBeanFactoryTargetSource
logger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidactivateObject(org.apache.commons.pool2.PooledObject<Object> p) protected org.apache.commons.pool2.ObjectPoolSubclasses can override this if they want to return a specific Commons pool.protected final voidCreates and holds an ObjectPool instance.voiddestroy()Closes the underlyingObjectPoolwhen destroying this object.voiddestroyObject(org.apache.commons.pool2.PooledObject<Object> p) intReturn the number of active objects in the pool.intReturn the number of idle objects in the pool.intReturn the maximum number of idle objects in the pool.longReturn the maximum waiting time for fetching an object from the pool.longReturn the minimum time that an idle object can sit in the pool.intReturn the minimum number of idle objects in the pool.Borrows an object from theObjectPool.longReturn the time between eviction runs that check idle objects.booleanSpecify if the call should block when the pool is exhausted.org.apache.commons.pool2.PooledObject<Object>voidpassivateObject(org.apache.commons.pool2.PooledObject<Object> p) voidreleaseTarget(Object target) Returns the specified object to the underlyingObjectPool.voidsetBlockWhenExhausted(boolean blockWhenExhausted) Set whether the call should bock when the pool is exhausted.voidsetMaxIdle(int maxIdle) Set the maximum number of idle objects in the pool.voidsetMaxWait(long maxWait) Set the maximum waiting time for fetching an object from the pool.voidsetMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) Set the minimum time that an idle object can sit in the pool before it becomes subject to eviction.voidsetMinIdle(int minIdle) Set the minimum number of idle objects in the pool.voidsetTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) Set the time between eviction runs that check idle objects whether they have been idle for too long or have become invalid.booleanvalidateObject(org.apache.commons.pool2.PooledObject<Object> p) 从类继承的方法 infra.aop.target.AbstractPoolingTargetSource
getMaxSize, getPoolingConfigMixin, setBeanFactory, setMaxSize从类继承的方法 infra.aop.target.AbstractPrototypeTargetSource
destroyPrototypeInstance, newPrototypeInstance, writeReplace从类继承的方法 infra.aop.target.AbstractBeanFactoryTargetSource
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, setTargetBeanName, setTargetClass, toString从接口继承的方法 org.apache.commons.pool2.PooledObjectFactory
destroyObject
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
maxIdle
private int maxIdle -
minIdle
private int minIdle -
maxWait
private long maxWait -
blockWhenExhausted
private boolean blockWhenExhausted -
minEvictableIdleTimeMillis
private long minEvictableIdleTimeMillis -
timeBetweenEvictionRunsMillis
private long timeBetweenEvictionRunsMillis -
pool
@Nullable private org.apache.commons.pool2.ObjectPool poolThe Apache CommonsObjectPoolused to pool target objects.
-
-
构造器详细资料
-
CommonsPool2TargetSource
public CommonsPool2TargetSource()Create a CommonsPoolTargetSource with default settings. Default maximum size of the pool is 8.- 另请参阅:
-
AbstractPoolingTargetSource.setMaxSize(int)GenericObjectPoolConfig.setMaxTotal(int)
-
-
方法详细资料
-
setMaxIdle
public void setMaxIdle(int maxIdle) Set the maximum number of idle objects in the pool. Default is 8.- 另请参阅:
-
GenericObjectPool.setMaxIdle(int)
-
getMaxIdle
public int getMaxIdle()Return the maximum number of idle objects in the pool. -
setMinIdle
public void setMinIdle(int minIdle) Set the minimum number of idle objects in the pool. Default is 0.- 另请参阅:
-
GenericObjectPool.setMinIdle(int)
-
getMinIdle
public int getMinIdle()Return the minimum number of idle objects in the pool. -
setMaxWait
public void setMaxWait(long maxWait) Set the maximum waiting time for fetching an object from the pool. Default is -1, waiting forever.- 另请参阅:
-
BaseGenericObjectPool.setMaxWaitMillis(long)
-
getMaxWait
public long getMaxWait()Return the maximum waiting time for fetching an object from the pool. -
setTimeBetweenEvictionRunsMillis
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) Set the time between eviction runs that check idle objects whether they have been idle for too long or have become invalid. Default is -1, not performing any eviction.- 另请参阅:
-
BaseGenericObjectPool.setTimeBetweenEvictionRunsMillis(long)
-
getTimeBetweenEvictionRunsMillis
public long getTimeBetweenEvictionRunsMillis()Return the time between eviction runs that check idle objects. -
setMinEvictableIdleTimeMillis
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) Set the minimum time that an idle object can sit in the pool before it becomes subject to eviction. Default is 1800000 (30 minutes).Note that eviction runs need to be performed to take this setting into effect.
- 另请参阅:
-
setTimeBetweenEvictionRunsMillis(long)BaseGenericObjectPool.setMinEvictableIdleTimeMillis(long)
-
getMinEvictableIdleTimeMillis
public long getMinEvictableIdleTimeMillis()Return the minimum time that an idle object can sit in the pool. -
setBlockWhenExhausted
public void setBlockWhenExhausted(boolean blockWhenExhausted) Set whether the call should bock when the pool is exhausted. -
isBlockWhenExhausted
public boolean isBlockWhenExhausted()Specify if the call should block when the pool is exhausted. -
createPool
protected final void createPool()Creates and holds an ObjectPool instance.- 指定者:
createPool在类中AbstractPoolingTargetSource- 另请参阅:
-
createObjectPool
protected org.apache.commons.pool2.ObjectPool createObjectPool()Subclasses can override this if they want to return a specific Commons pool. They should apply any configuration properties to the pool here.Default is a GenericObjectPool instance with the given pool size.
- 返回:
- an empty Commons
ObjectPool. - 另请参阅:
-
GenericObjectPoolAbstractPoolingTargetSource.setMaxSize(int)
-
getTarget
Borrows an object from theObjectPool.- 指定者:
getTarget在接口中TargetSource- 指定者:
getTarget在类中AbstractPoolingTargetSource- 返回:
- an object from the pool
- 抛出:
Exception- we may need to deal with checked exceptions from pool APIs, so we're forgiving with our exception signature
-
releaseTarget
Returns the specified object to the underlyingObjectPool.- 指定者:
releaseTarget在接口中TargetSource- 指定者:
releaseTarget在类中AbstractPoolingTargetSource- 参数:
target- object that must have been acquired from the pool via a call togetTarget()- 抛出:
Exception- to allow pooling APIs to throw exception- 另请参阅:
-
getActiveCount
从接口复制的说明:PoolingConfigReturn the number of active objects in the pool.- 指定者:
getActiveCount在接口中PoolingConfig- 抛出:
UnsupportedOperationException- if not supported by the pool
-
getIdleCount
从接口复制的说明:PoolingConfigReturn the number of idle objects in the pool.- 指定者:
getIdleCount在接口中PoolingConfig- 抛出:
UnsupportedOperationException- if not supported by the pool
-
destroy
Closes the underlyingObjectPoolwhen destroying this object.- 指定者:
destroy在接口中infra.beans.factory.DisposableBean- 抛出:
Exception
-
makeObject
-
destroyObject
- 指定者:
destroyObject在接口中org.apache.commons.pool2.PooledObjectFactory<Object>
-
validateObject
- 指定者:
validateObject在接口中org.apache.commons.pool2.PooledObjectFactory<Object>
-
activateObject
- 指定者:
activateObject在接口中org.apache.commons.pool2.PooledObjectFactory<Object>
-
passivateObject
- 指定者:
passivateObject在接口中org.apache.commons.pool2.PooledObjectFactory<Object>
-