gate.util.spring.xml
Class PoolFiller
java.lang.Object
gate.util.spring.xml.PoolFiller
- All Implemented Interfaces:
- org.springframework.beans.factory.InitializingBean
public class PoolFiller
- extends Object
- implements org.springframework.beans.factory.InitializingBean
Simple bean that takes a pooled target source and performs a sequence
of n getTarget calls followed by n releaseTarget calls. This has the
effect of pre-populating the pool with n instances up-front (normally
a pooled target source only creates objects the first time they are
required). Note that if the specified number of instances is greater
than the maximum size of the pool the number of calls will be reduced
accordingly.
|
Method Summary |
void |
afterPropertiesSet()
|
private void |
checkoutTargets(int num)
Recursive helper method to check out num targets
from the target source and then release them, with proper
try/finally handling in case of exceptions. |
void |
setNumInstances(int numInstances)
Set the number of nested get/release calls to make. |
void |
setTargetSource(org.springframework.aop.target.AbstractPoolingTargetSource targetSource)
Set the target source to be populated. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
targetSource
private org.springframework.aop.target.AbstractPoolingTargetSource targetSource
numInstances
private int numInstances
PoolFiller
public PoolFiller()
setTargetSource
public void setTargetSource(org.springframework.aop.target.AbstractPoolingTargetSource targetSource)
- Set the target source to be populated.
setNumInstances
public void setNumInstances(int numInstances)
- Set the number of nested get/release calls to make. The actual
number of calls made is the minimum of this value and the maximum
size of the pool.
afterPropertiesSet
public void afterPropertiesSet()
throws Exception
- Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
- Throws:
Exception
checkoutTargets
private void checkoutTargets(int num)
throws Exception
- Recursive helper method to check out
num targets
from the target source and then release them, with proper
try/finally handling in case of exceptions. If the target source is
backed by a pool this will have the effect of forcing upfront
creation of at least num instances in the pool.
- Throws:
Exception