|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource org.springframework.aop.target.AbstractPrototypeBasedTargetSource org.springframework.aop.target.AbstractPoolingTargetSource
Abstract superclass for pooling TargetSources that maintains a pool of target instances, acquiring and releasing a target object from the pool for each method invocation. This class is independent of pooling technology.
Subclasses must implement the getTarget() and releaseTarget() methods to work with their chosen pool. The newPrototypeInstance() method inherited from AbstractPrototypeBasedTargetSource can be used to create objects to put in the pool. Subclasses must also implement some of the monitoring methods from the PoolingConfig interface. This class provides the getPoolingConfigMixin() method to return an IntroductionAdvisor making these stats available on proxied objects.
This class implements DisposableBean to force subclasses to implement a destroy() method to close down their pool.
getTarget()
,
releaseTarget(java.lang.Object)
,
DisposableBean.destroy()
,
Serialized FormField Summary |
Fields inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource |
logger |
Constructor Summary | |
AbstractPoolingTargetSource()
|
Method Summary | |
protected abstract void |
createPool(BeanFactory beanFactory)
Create the pool. |
int |
getMaxSize()
Return the maximum size of the pool. |
DefaultIntroductionAdvisor |
getPoolingConfigMixin()
Return an IntroductionAdvisor that providing a mixin exposing statistics about the pool maintained by this object. |
abstract Object |
getTarget()
Acquire an object from the pool. |
abstract void |
releaseTarget(Object target)
Return the given object to the pool. |
void |
setBeanFactory(BeanFactory beanFactory)
Set the owning BeanFactory. |
void |
setMaxSize(int maxSize)
Set the maximum size of the pool. |
Methods inherited from class org.springframework.aop.target.AbstractPrototypeBasedTargetSource |
newPrototypeInstance |
Methods inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource |
getBeanFactory, getTargetBeanName, getTargetClass, isStatic, setTargetBeanName, writeReplace |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.aop.target.PoolingConfig |
getActive, getActiveCount, getFree, getIdleCount |
Methods inherited from interface org.springframework.beans.factory.DisposableBean |
destroy |
Constructor Detail |
public AbstractPoolingTargetSource()
Method Detail |
public void setMaxSize(int maxSize)
public int getMaxSize()
getMaxSize
in interface PoolingConfig
public final void setBeanFactory(BeanFactory beanFactory) throws BeansException
AbstractBeanFactoryBasedTargetSource
getBean
method on every invocation.
setBeanFactory
in interface BeanFactoryAware
setBeanFactory
in class AbstractPrototypeBasedTargetSource
BeansException
protected abstract void createPool(BeanFactory beanFactory) throws Exception
beanFactory
- owning BeanFactory, in case we need collaborators from it
(normally our own properties are sufficient)
Exception
- to avoid placing constraints on pooling APIspublic abstract Object getTarget() throws Exception
getTarget
in interface TargetSource
Exception
- we may need to deal with checked exceptions from pool
APIs, so we're forgiving with our exception signaturepublic abstract void releaseTarget(Object target) throws Exception
releaseTarget
in interface TargetSource
releaseTarget
in class AbstractBeanFactoryBasedTargetSource
target
- object that must have been acquired from the pool
via a call to getTarget()
Exception
- to allow pooling APIs to throw exceptiongetTarget()
public DefaultIntroductionAdvisor getPoolingConfigMixin()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |