TargetSource implementation that holds objects in a configurable
Jakarta Commons Pool.
| Method from org.springframework.aop.target.CommonsPoolTargetSource Detail: |
public void activateObject(Object obj) {
}
|
protected ObjectPool createObjectPool() {
GenericObjectPool gop = new GenericObjectPool(this);
gop.setMaxActive(getMaxSize());
gop.setMaxIdle(getMaxIdle());
gop.setMinIdle(getMinIdle());
gop.setMaxWait(getMaxWait());
gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
gop.setWhenExhaustedAction(getWhenExhaustedAction());
return gop;
}
|
protected final void createPool() {
logger.debug("Creating Commons object pool");
this.pool = createObjectPool();
}
Creates and holds an ObjectPool instance. |
public void destroy() throws Exception {
logger.debug("Closing Commons ObjectPool");
this.pool.close();
}
Closes the underlying ObjectPool when destroying this object. |
public void destroyObject(Object obj) throws Exception {
destroyPrototypeInstance(obj);
}
|
public int getActiveCount() throws UnsupportedOperationException {
return this.pool.getNumActive();
}
|
public int getIdleCount() throws UnsupportedOperationException {
return this.pool.getNumIdle();
}
|
public int getMaxIdle() {
return this.maxIdle;
}
Return the maximum number of idle objects in the pool. |
public long getMaxWait() {
return this.maxWait;
}
Return the maximum waiting time for fetching an object from the pool. |
public long getMinEvictableIdleTimeMillis() {
return this.minEvictableIdleTimeMillis;
}
Return the minimum time that an idle object can sit in the pool. |
public int getMinIdle() {
return this.minIdle;
}
Return the minimum number of idle objects in the pool. |
public Object getTarget() throws Exception {
return this.pool.borrowObject();
}
Borrow an object from the ObjectPool. |
public long getTimeBetweenEvictionRunsMillis() {
return this.timeBetweenEvictionRunsMillis;
}
Return the time between eviction runs that check idle objects. |
public byte getWhenExhaustedAction() {
return whenExhaustedAction;
}
Return the action to take when the pool is exhausted. |
public Object makeObject() throws BeansException {
return newPrototypeInstance();
}
|
public void passivateObject(Object obj) {
}
|
public void releaseTarget(Object target) throws Exception {
this.pool.returnObject(target);
}
Returns the specified object to the underlying ObjectPool. |
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
Set the maximum number of idle objects in the pool.
Default is 8. |
public void setMaxWait(long maxWait) {
this.maxWait = maxWait;
}
Set the maximum waiting time for fetching an object from the pool.
Default is -1, waiting forever. |
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
|
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
Set the minimum number of idle objects in the pool.
Default is 0. |
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}
Set the time between eviction runs that check idle objects whether
they have been idle for too long or have become invalid.
Default is -1, not performing any eviction. |
public void setWhenExhaustedAction(byte whenExhaustedAction) {
this.whenExhaustedAction = whenExhaustedAction;
}
Set the action to take when the pool is exhausted. Uses the
constant values defined in Commons Pool's GenericObjectPool class. |
public void setWhenExhaustedActionName(String whenExhaustedActionName) {
setWhenExhaustedAction(constants.asNumber(whenExhaustedActionName).byteValue());
}
Set the action to take when the pool is exhausted. Uses the
constant names defined in Commons Pool's GenericObjectPool class:
"WHEN_EXHAUSTED_BLOCK", "WHEN_EXHAUSTED_FAIL", "WHEN_EXHAUSTED_GROW". |
public boolean validateObject(Object obj) {
return true;
}
|