org.springframework.aop.target
Class CommonsPoolTargetSource

java.lang.Object
  extended byorg.springframework.aop.target.AbstractPrototypeTargetSource
      extended byorg.springframework.aop.target.AbstractPoolingTargetSource
          extended byorg.springframework.aop.target.CommonsPoolTargetSource
All Implemented Interfaces:
BeanFactoryAware, DisposableBean, InitializingBean, org.apache.commons.pool.PoolableObjectFactory, PoolingConfig, TargetSource

public class CommonsPoolTargetSource
extends AbstractPoolingTargetSource
implements org.apache.commons.pool.PoolableObjectFactory

Jakarta Commons pooling implementation extending AbstractPoolingInvokerInterceptor

Version:
$Id: CommonsPoolTargetSource.java,v 1.4 2004/03/18 02:46:13 trisberg Exp $
Author:
Rod Johnson

Field Summary
 
Fields inherited from class org.springframework.aop.target.AbstractPrototypeTargetSource
logger
 
Constructor Summary
CommonsPoolTargetSource()
           
 
Method Summary
 void activateObject(java.lang.Object o)
           
protected  org.apache.commons.pool.ObjectPool createObjectPool()
          Subclasses can override this if they want to return a different Commons pool to GenericObject pool.
protected  void createPool(BeanFactory beanFactory)
          Create the pool.
 void destroy()
          Invoked by a BeanFactory on destruction of a singleton.
 void destroyObject(java.lang.Object o)
           
 int getActive()
           
 int getFree()
           
 java.lang.Object getTarget()
          Acquire an object from the pool.
 java.lang.Object makeObject()
           
 void passivateObject(java.lang.Object o)
           
 void releaseTarget(java.lang.Object target)
          Return the given object to the pool.
 boolean validateObject(java.lang.Object o)
           
 
Methods inherited from class org.springframework.aop.target.AbstractPoolingTargetSource
getMaxSize, getPoolingConfigMixin, setBeanFactory, setMaxSize
 
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
 

Constructor Detail

CommonsPoolTargetSource

public CommonsPoolTargetSource()
Method Detail

createPool

protected final void createPool(BeanFactory beanFactory)
Description copied from class: AbstractPoolingTargetSource
Create the pool.

Specified by:
createPool in class AbstractPoolingTargetSource
Parameters:
beanFactory - owning BeanFactory, in case we need collaborators from it (normally our own properties are sufficient)
See Also:
BeanFactoryAware.setBeanFactory(org.springframework.beans.factory.BeanFactory)

createObjectPool

protected org.apache.commons.pool.ObjectPool createObjectPool()
Subclasses can override this if they want to return a different Commons pool to GenericObject pool. They should apply properties to the pool here

Returns:
an empty Commons pool

getTarget

public java.lang.Object getTarget()
                           throws java.lang.Exception
Description copied from class: AbstractPoolingTargetSource
Acquire an object from the pool.

Specified by:
getTarget in interface TargetSource
Specified by:
getTarget in class AbstractPoolingTargetSource
Returns:
an object from the pool
Throws:
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 Exception

releaseTarget

public void releaseTarget(java.lang.Object target)
                   throws java.lang.Exception
Description copied from class: AbstractPoolingTargetSource
Return the given object to the pool.

Specified by:
releaseTarget in interface TargetSource
Specified by:
releaseTarget in class AbstractPoolingTargetSource
Parameters:
target - object that must have been acquired from the pool via a call to acquireTarget()
Throws:
java.lang.Exception - to allow pooling APIs to throw exception

getActive

public int getActive()
Specified by:
getActive in interface PoolingConfig

getFree

public int getFree()
Specified by:
getFree in interface PoolingConfig

destroy

public void destroy()
             throws java.lang.Exception
Description copied from interface: DisposableBean
Invoked by a BeanFactory on destruction of a singleton.

Specified by:
destroy in interface DisposableBean
Throws:
java.lang.Exception - in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources too.
See Also:
DisposableBean.destroy()

makeObject

public java.lang.Object makeObject()
Specified by:
makeObject in interface org.apache.commons.pool.PoolableObjectFactory
See Also:
PoolableObjectFactory.makeObject()

destroyObject

public void destroyObject(java.lang.Object o)
                   throws java.lang.Exception
Specified by:
destroyObject in interface org.apache.commons.pool.PoolableObjectFactory
Throws:
java.lang.Exception
See Also:
PoolableObjectFactory.destroyObject(java.lang.Object)

validateObject

public boolean validateObject(java.lang.Object o)
Specified by:
validateObject in interface org.apache.commons.pool.PoolableObjectFactory
See Also:
PoolableObjectFactory.validateObject(java.lang.Object)

activateObject

public void activateObject(java.lang.Object o)
                    throws java.lang.Exception
Specified by:
activateObject in interface org.apache.commons.pool.PoolableObjectFactory
Throws:
java.lang.Exception
See Also:
PoolableObjectFactory.activateObject(java.lang.Object)

passivateObject

public void passivateObject(java.lang.Object o)
                     throws java.lang.Exception
Specified by:
passivateObject in interface org.apache.commons.pool.PoolableObjectFactory
Throws:
java.lang.Exception
See Also:
PoolableObjectFactory.passivateObject(java.lang.Object)


Copyright (C) 2003-2004 The Spring Framework Project.