Class CommonsPoolTargetSource
- java.lang.Object
- org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
- org.springframework.aop.target.AbstractPrototypeBasedTargetSource
- org.springframework.aop.target.AbstractPoolingTargetSource
- org.springframework.aop.target.CommonsPoolTargetSource
- All Implemented Interfaces:
Serializable,org.apache.commons.pool.PoolableObjectFactory,PoolingConfig,TargetClassAware,TargetSource,Aware,BeanFactoryAware,DisposableBean
@Deprecated public class CommonsPoolTargetSource extends AbstractPoolingTargetSource implements org.apache.commons.pool.PoolableObjectFactory
Deprecated.as of Spring 4.2, in favor ofCommonsPool2TargetSourceTargetSourceimplementation that holds objects in a configurable Apache Commons Pool.By default, an instance of
GenericObjectPoolis created. Subclasses may change the type ofObjectPoolused by overriding thecreateObjectPool()method.Provides many configuration properties mirroring those of the Commons Pool
GenericObjectPoolclass; these properties are passed to theGenericObjectPoolduring construction. If creating a subclass of this class to change theObjectPoolimplementation type, pass in the values of configuration properties that are relevant to your chosen implementation.The
testOnBorrow,testOnReturnandtestWhileIdleproperties are explicitly not mirrored because the implementation ofPoolableObjectFactoryused by this class does not implement meaningful validation. All exposed Commons Pool properties use the corresponding Commons Pool defaults.Compatible with Apache Commons Pool 1.5.x and 1.6. Note that this class doesn't declare Commons Pool 1.6's generic type in order to remain compatible with Commons Pool 1.5.x at runtime.
- Author:
- Rod Johnson, Rob Harrop, Juergen Hoeller
- See Also:
GenericObjectPool,createObjectPool(),AbstractPoolingTargetSource.setMaxSize(int),setMaxIdle(int),setMinIdle(int),setMaxWait(long),setTimeBetweenEvictionRunsMillis(long),setMinEvictableIdleTimeMillis(long), Serialized Form
Field Summary
Fields inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
logger
Constructor Summary
Constructors Constructor Description CommonsPoolTargetSource()Deprecated.Create a CommonsPoolTargetSource with default settings.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidactivateObject(Object obj)Deprecated.protected org.apache.commons.pool.ObjectPoolcreateObjectPool()Deprecated.Subclasses can override this if they want to return a specific Commons pool.protected voidcreatePool()Deprecated.Creates and holds an ObjectPool instance.voiddestroy()Deprecated.Closes the underlyingObjectPoolwhen destroying this object.voiddestroyObject(Object obj)Deprecated.intgetActiveCount()Deprecated.Return the number of active objects in the pool.intgetIdleCount()Deprecated.Return the number of idle objects in the pool.intgetMaxIdle()Deprecated.Return the maximum number of idle objects in the pool.longgetMaxWait()Deprecated.Return the maximum waiting time for fetching an object from the pool.longgetMinEvictableIdleTimeMillis()Deprecated.Return the minimum time that an idle object can sit in the pool.intgetMinIdle()Deprecated.Return the minimum number of idle objects in the pool.ObjectgetTarget()Deprecated.Borrow an object from theObjectPool.longgetTimeBetweenEvictionRunsMillis()Deprecated.Return the time between eviction runs that check idle objects.bytegetWhenExhaustedAction()Deprecated.Return the action to take when the pool is exhausted.ObjectmakeObject()Deprecated.voidpassivateObject(Object obj)Deprecated.voidreleaseTarget(Object target)Deprecated.Returns the specified object to the underlyingObjectPool.voidsetMaxIdle(int maxIdle)Deprecated.Set the maximum number of idle objects in the pool.voidsetMaxWait(long maxWait)Deprecated.Set the maximum waiting time for fetching an object from the pool.voidsetMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)Deprecated.Set the minimum time that an idle object can sit in the pool before it becomes subject to eviction.voidsetMinIdle(int minIdle)Deprecated.Set the minimum number of idle objects in the pool.voidsetTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)Deprecated.Set the time between eviction runs that check idle objects whether they have been idle for too long or have become invalid.voidsetWhenExhaustedAction(byte whenExhaustedAction)Deprecated.Set the action to take when the pool is exhausted.voidsetWhenExhaustedActionName(String whenExhaustedActionName)Deprecated.Set the action to take when the pool is exhausted.booleanvalidateObject(Object obj)Deprecated.Methods inherited from class org.springframework.aop.target.AbstractPoolingTargetSource
getMaxSize, getPoolingConfigMixin, setBeanFactory, setMaxSize
Methods inherited from class org.springframework.aop.target.AbstractPrototypeBasedTargetSource
destroyPrototypeInstance, newPrototypeInstance, writeReplace
Methods inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, setTargetBeanName, setTargetClass, toString
Constructor Detail
CommonsPoolTargetSource
public CommonsPoolTargetSource()
Deprecated.Create a CommonsPoolTargetSource with default settings. Default maximum size of the pool is 8.- See Also:
AbstractPoolingTargetSource.setMaxSize(int),GenericObjectPool.setMaxActive(int)
Method Detail
setMaxIdle
public void setMaxIdle(int maxIdle)
Deprecated.Set the maximum number of idle objects in the pool. Default is 8.- See Also:
GenericObjectPool.setMaxIdle(int)
getMaxIdle
public int getMaxIdle()
Deprecated.Return the maximum number of idle objects in the pool.
setMinIdle
public void setMinIdle(int minIdle)
Deprecated.Set the minimum number of idle objects in the pool. Default is 0.- See Also:
GenericObjectPool.setMinIdle(int)
getMinIdle
public int getMinIdle()
Deprecated.Return the minimum number of idle objects in the pool.
setMaxWait
public void setMaxWait(long maxWait)
Deprecated.Set the maximum waiting time for fetching an object from the pool. Default is -1, waiting forever.- See Also:
GenericObjectPool.setMaxWait(long)
getMaxWait
public long getMaxWait()
Deprecated.Return the maximum waiting time for fetching an object from the pool.
setTimeBetweenEvictionRunsMillis
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
Deprecated.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.- See Also:
GenericObjectPool.setTimeBetweenEvictionRunsMillis(long)
getTimeBetweenEvictionRunsMillis
public long getTimeBetweenEvictionRunsMillis()
Deprecated.Return the time between eviction runs that check idle objects.
setMinEvictableIdleTimeMillis
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
Deprecated.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.
- See Also:
setTimeBetweenEvictionRunsMillis(long),GenericObjectPool.setMinEvictableIdleTimeMillis(long)
getMinEvictableIdleTimeMillis
public long getMinEvictableIdleTimeMillis()
Deprecated.Return the minimum time that an idle object can sit in the pool.
setWhenExhaustedActionName
public void setWhenExhaustedActionName(String whenExhaustedActionName)
Deprecated.Set the action to take when the pool is exhausted. Uses the constant names defined in Commons Pool's GenericObjectPool class: "WHEN_EXHAUSTED_BLOCK", "WHEN_EXHAUSTED_FAIL", "WHEN_EXHAUSTED_GROW".- See Also:
setWhenExhaustedAction(byte)
setWhenExhaustedAction
public void setWhenExhaustedAction(byte whenExhaustedAction)
Deprecated.Set the action to take when the pool is exhausted. Uses the constant values defined in Commons Pool's GenericObjectPool class.- See Also:
GenericObjectPool.setWhenExhaustedAction(byte),GenericObjectPool.WHEN_EXHAUSTED_BLOCK,GenericObjectPool.WHEN_EXHAUSTED_FAIL,GenericObjectPool.WHEN_EXHAUSTED_GROW
getWhenExhaustedAction
public byte getWhenExhaustedAction()
Deprecated.Return the action to take when the pool is exhausted.
createPool
protected final void createPool()
Deprecated.Creates and holds an ObjectPool instance.- Specified by:
createPoolin classAbstractPoolingTargetSource- See Also:
createObjectPool()
createObjectPool
protected org.apache.commons.pool.ObjectPool createObjectPool()
Deprecated.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.
- Returns:
- an empty Commons
ObjectPool. - See Also:
GenericObjectPool,AbstractPoolingTargetSource.setMaxSize(int)
getTarget
public Object getTarget() throws Exception
Deprecated.Borrow an object from theObjectPool.- Specified by:
getTargetin interfaceTargetSource- Specified by:
getTargetin classAbstractPoolingTargetSource- Returns:
- an object from the pool
- Throws:
Exception- we may need to deal with checked exceptions from pool APIs, so we're forgiving with our exception signature
releaseTarget
public void releaseTarget(Object target) throws Exception
Deprecated.Returns the specified object to the underlyingObjectPool.- Specified by:
releaseTargetin interfaceTargetSource- Specified by:
releaseTargetin classAbstractPoolingTargetSource- Parameters:
target- object that must have been acquired from the pool via a call togetTarget()- Throws:
Exception- to allow pooling APIs to throw exception- See Also:
AbstractPoolingTargetSource.getTarget()
getActiveCount
public int getActiveCount() throws UnsupportedOperationException
Deprecated.Description copied from interface:PoolingConfigReturn the number of active objects in the pool.- Specified by:
getActiveCountin interfacePoolingConfig- Throws:
UnsupportedOperationException- if not supported by the pool
getIdleCount
public int getIdleCount() throws UnsupportedOperationException
Deprecated.Description copied from interface:PoolingConfigReturn the number of idle objects in the pool.- Specified by:
getIdleCountin interfacePoolingConfig- Throws:
UnsupportedOperationException- if not supported by the pool
destroy
public void destroy() throws Exception
Deprecated.Closes the underlyingObjectPoolwhen destroying this object.- Specified by:
destroyin interfaceDisposableBean- Throws:
Exception- in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources as well.
makeObject
public Object makeObject() throws BeansException
Deprecated.- Specified by:
makeObjectin interfaceorg.apache.commons.pool.PoolableObjectFactory- Throws:
BeansException
destroyObject
public void destroyObject(Object obj) throws Exception
Deprecated.- Specified by:
destroyObjectin interfaceorg.apache.commons.pool.PoolableObjectFactory- Throws:
Exception
validateObject
public boolean validateObject(Object obj)
Deprecated.- Specified by:
validateObjectin interfaceorg.apache.commons.pool.PoolableObjectFactory
activateObject
public void activateObject(Object obj)
Deprecated.- Specified by:
activateObjectin interfaceorg.apache.commons.pool.PoolableObjectFactory
passivateObject
public void passivateObject(Object obj)
Deprecated.- Specified by:
passivateObjectin interfaceorg.apache.commons.pool.PoolableObjectFactory