org.springframework.aop.target
abstract public class: AbstractPoolingTargetSource [javadoc |
source]
java.lang.Object
org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
org.springframework.aop.target.AbstractPrototypeBasedTargetSource
org.springframework.aop.target.AbstractPoolingTargetSource
All Implemented Interfaces:
DisposableBean, PoolingConfig, TargetSource, BeanFactoryAware, Serializable
Direct Known Subclasses:
CommonsPoolTargetSource
Abstract base class for pooling
org.springframework.aop.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
CommonsPoolTargetSource for a concrete example.
Subclasses must implement the #getTarget and
#releaseTarget methods based on their chosen object pool.
The #newPrototypeInstance() method inherited from
AbstractPrototypeBasedTargetSource can be used to create objects
in order to put them into the pool.
Subclasses must also implement some of the monitoring methods from the
PoolingConfig interface. The #getPoolingConfigMixin() method
makes these stats available on proxied objects through an IntroductionAdvisor.
This class implements the org.springframework.beans.factory.DisposableBean
interface in order to force subclasses to implement a #destroy()
method, closing down their object pool.
| Methods from org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource: |
|---|
|
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, releaseTarget, setBeanFactory, setTargetBeanName, setTargetClass, toString, writeReplace |
| Method from org.springframework.aop.target.AbstractPoolingTargetSource Detail: |
abstract protected void createPool() throws Exception
|
public int getMaxSize() {
return this.maxSize;
}
Return the maximum size of the pool. |
public DefaultIntroductionAdvisor getPoolingConfigMixin() {
DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(this);
return new DefaultIntroductionAdvisor(dii, PoolingConfig.class);
}
Return an IntroductionAdvisor that providing a mixin
exposing statistics about the pool maintained by this object. |
abstract public Object getTarget() throws Exception
Acquire an object from the pool. |
abstract public void releaseTarget(Object target) throws Exception
Return the given object to the pool. |
public final void setBeanFactory(BeanFactory beanFactory) throws BeansException {
super.setBeanFactory(beanFactory);
try {
createPool();
}
catch (Throwable ex) {
throw new BeanInitializationException("Could not create instance pool for TargetSource", ex);
}
}
|
public void setMaxSize(int maxSize) {
this.maxSize = maxSize;
}
Set the maximum size of the pool.
Default is -1, indicating no size limit. |