|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.aop.target.AbstractPrototypeTargetSource org.springframework.aop.target.AbstractPoolingTargetSource
Abstract uperclass 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 AbstractPrototypeTargetSource 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.
Field Summary |
Fields inherited from class org.springframework.aop.target.AbstractPrototypeTargetSource |
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()
|
abstract java.lang.Object |
getTarget()
Acquire an object from the pool. |
abstract void |
releaseTarget(java.lang.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.AbstractPrototypeTargetSource |
afterPropertiesSet, getTargetBeanName, getTargetClass, isStatic, newPrototypeInstance, setTargetBeanName |
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, getFree |
Methods inherited from interface org.springframework.beans.factory.DisposableBean |
destroy |
Constructor Detail |
public AbstractPoolingTargetSource()
Method Detail |
public void setMaxSize(int maxSize)
maxSize
- the size for the poolpublic int getMaxSize()
getMaxSize
in interface PoolingConfig
public final void setBeanFactory(BeanFactory beanFactory) throws BeansException
AbstractPrototypeTargetSource
setBeanFactory
in interface BeanFactoryAware
setBeanFactory
in class AbstractPrototypeTargetSource
BeansException
protected abstract void createPool(BeanFactory beanFactory) throws java.lang.Exception
beanFactory
- owning BeanFactory, in case we need collaborators from it
(normally our own properties are sufficient)
java.lang.Exception
- to avoid placing constraints on pooling APIspublic abstract java.lang.Object getTarget() throws java.lang.Exception
getTarget
in interface TargetSource
java.lang.Exception
- we may need to deal with checked exceptions from pool
APIs, so we're forgiving with our exception signature,
although we don't like APIs that throw Exceptionpublic abstract void releaseTarget(java.lang.Object target) throws java.lang.Exception
releaseTarget
in interface TargetSource
target
- object that must have been acquired from the pool
via a call to acquireTarget()
java.lang.Exception
- to allow pooling APIs to throw exceptionpublic DefaultIntroductionAdvisor getPoolingConfigMixin()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |