Package org.springframework.aop.target
Class AbstractPoolingTargetSource
java.lang.Object
org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
org.springframework.aop.target.AbstractPrototypeBasedTargetSource
org.springframework.aop.target.AbstractPoolingTargetSource
- All Implemented Interfaces:
- Serializable,- PoolingConfig,- TargetClassAware,- TargetSource,- Aware,- BeanFactoryAware,- DisposableBean
- Direct Known Subclasses:
- CommonsPool2TargetSource
public abstract class AbstractPoolingTargetSource
extends AbstractPrototypeBasedTargetSource
implements PoolingConfig, DisposableBean
Abstract base class for pooling 
TargetSource
 implementations which maintain a pool of target instances, acquiring and
 releasing a target object from the pool for each method invocation.
 This abstract base class is independent of concrete pooling technology;
 see the subclass CommonsPool2TargetSource for a concrete example.
 Subclasses must implement the getTarget() and
 releaseTarget(java.lang.Object) methods based on their chosen object pool.
 The AbstractPrototypeBasedTargetSource.newPrototypeInstance() method inherited from
 AbstractPrototypeBasedTargetSource can be used to create objects
 in order to put them into the pool.
 
Subclasses must also implement some monitoring methods from the
 PoolingConfig interface. The getPoolingConfigMixin() method
 makes these stats available on proxied objects through an IntroductionAdvisor.
 
This class implements the DisposableBean
 interface in order to force subclasses to implement a DisposableBean.destroy()
 method, closing down their object pool.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSourcelogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voidCreate the pool.intReturn the maximum size of the pool.Return an IntroductionAdvisor that provides a mixin exposing statistics about the pool maintained by this object.Acquire an object from the pool.abstract voidreleaseTarget(Object target) Return the given object to the pool.final voidsetBeanFactory(BeanFactory beanFactory) Set the owning BeanFactory.voidsetMaxSize(int maxSize) Set the maximum size of the pool.Methods inherited from class org.springframework.aop.target.AbstractPrototypeBasedTargetSourcedestroyPrototypeInstance, newPrototypeInstance, writeReplaceMethods inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSourcecopyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, setTargetBeanName, setTargetClass, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.DisposableBeandestroyMethods inherited from interface org.springframework.aop.target.PoolingConfiggetActiveCount, getIdleCountMethods inherited from interface org.springframework.aop.TargetSourceisStatic
- 
Constructor Details- 
AbstractPoolingTargetSourcepublic AbstractPoolingTargetSource()
 
- 
- 
Method Details- 
setMaxSizepublic void setMaxSize(int maxSize) Set the maximum size of the pool. Default is -1, indicating no size limit.
- 
getMaxSizepublic int getMaxSize()Return the maximum size of the pool.- Specified by:
- getMaxSizein interface- PoolingConfig
 
- 
setBeanFactoryDescription copied from class:AbstractBeanFactoryBasedTargetSourceSet the owning BeanFactory. We need to save a reference so that we can use thegetBeanmethod on every invocation.- Specified by:
- setBeanFactoryin interface- BeanFactoryAware
- Overrides:
- setBeanFactoryin class- AbstractPrototypeBasedTargetSource
- Parameters:
- beanFactory- owning BeanFactory (never- null). The bean can immediately call methods on the factory.
- Throws:
- BeansException- in case of initialization errors
- See Also:
 
- 
createPoolCreate the pool.- Throws:
- Exception- to avoid placing constraints on pooling APIs
 
- 
getTargetAcquire an object from the pool.- Specified by:
- getTargetin interface- TargetSource
- 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
 
- 
releaseTargetReturn the given object to the pool.- Specified by:
- releaseTargetin interface- TargetSource
- Parameters:
- target- object that must have been acquired from the pool via a call to- getTarget()
- Throws:
- Exception- to allow pooling APIs to throw exception
- See Also:
 
- 
getPoolingConfigMixinReturn an IntroductionAdvisor that provides a mixin exposing statistics about the pool maintained by this object.
 
-