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 CommonsPool2TargetSource 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 monitoring methods from the
PoolingConfig interface. The getPoolingConfigMixin() method
makes these stats available on proxied objects through an IntroductionAdvisor.
This class implements the org.
interface in order to force subclasses to implement a destroy()
method, closing down their object pool.
getTarget, releaseTarget, destroy
| Modifier and Type | Field and Description |
|---|---|
| private int | maxSize
The maximum size of the pool. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract void | |
| public int | getMaxSize()
Implements org. |
| public DefaultIntroductionAdvisor | getPoolingConfigMixin()
Return an IntroductionAdvisor that provides a mixin exposing statistics about the pool maintained by this object. |
| public abstract Object | Returns: an object from the poolRedeclares org. |
| public abstract void | releaseTarget(Object
object that must have been acquired from the pool
via a call to target)getTarget()Redeclares as abstract: org. |
| public final void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Overrides org. Implements org. |
| public void |
| maxSize | back to summary |
|---|---|
| private int maxSize The maximum size of the pool. | |
| AbstractPoolingTargetSource | back to summary |
|---|---|
| public AbstractPoolingTargetSource() | |
| createPool | back to summary |
|---|---|
| protected abstract void createPool() throws Exception Create the pool.
| |
| getMaxSize | back to summary |
|---|---|
| public int getMaxSize() Implements org. Return the maximum size of the pool.
| |
| getPoolingConfigMixin | back to summary |
|---|---|
| public DefaultIntroductionAdvisor getPoolingConfigMixin() Return an IntroductionAdvisor that provides a mixin exposing statistics about the pool maintained by this object. | |
| getTarget | back to summary |
|---|---|
| public abstract Object getTarget() throws Exception Redeclares org. Acquire an object from the pool. | |
| releaseTarget | back to summary |
|---|---|
| public abstract void releaseTarget(Object target) throws Exception Redeclares as abstract: org. Return the given object to the pool. | |
| setBeanFactory | back to summary |
|---|---|
| public final void setBeanFactory(BeanFactory beanFactory) throws BeansException Overrides org. Implements org. Doc from org. Set the owning BeanFactory. We need to save a reference so that we can
use the
| |
| setMaxSize | back to summary |
|---|---|
| public void setMaxSize(int maxSize) Set the maximum size of the pool. Default is -1, indicating no size limit. | |