org.springframework.aop.target
Class CommonsPoolTargetSource

java.lang.Object
  extended byorg.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
      extended byorg.springframework.aop.target.AbstractPrototypeBasedTargetSource
          extended byorg.springframework.aop.target.AbstractPoolingTargetSource
              extended byorg.springframework.aop.target.CommonsPoolTargetSource
All Implemented Interfaces:
BeanFactoryAware, DisposableBean, PoolableObjectFactory, PoolingConfig, Serializable, TargetSource

public class CommonsPoolTargetSource
extends AbstractPoolingTargetSource
implements PoolableObjectFactory

Jakarta Commons pooling implementation extending AbstractPoolingTargetSource.

Author:
Rod Johnson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
logger
 
Constructor Summary
CommonsPoolTargetSource()
           
 
Method Summary
 void activateObject(Object o)
           
protected  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(Object o)
           
 int getActive()
          Deprecated. in favor of getActiveCount
 int getActiveCount()
          Return the number of active objects in the pool.
 int getFree()
          Deprecated. in favor of getIdleCount
 int getIdleCount()
          Return the number of idle objects in the pool.
 Object getTarget()
          Acquire an object from the pool.
 Object makeObject()
           
 void passivateObject(Object o)
           
 void releaseTarget(Object target)
          Return the given object to the pool.
 boolean validateObject(Object o)
           
 
Methods inherited from class org.springframework.aop.target.AbstractPoolingTargetSource
getMaxSize, getPoolingConfigMixin, setBeanFactory, setMaxSize
 
Methods inherited from class org.springframework.aop.target.AbstractPrototypeBasedTargetSource
newPrototypeInstance
 
Methods inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
getBeanFactory, getTargetBeanName, getTargetClass, isStatic, setTargetBeanName, writeReplace
 
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)

createObjectPool

protected 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 Object getTarget()
                 throws 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:
Exception - we may need to deal with checked exceptions from pool APIs, so we're forgiving with our exception signature

releaseTarget

public void releaseTarget(Object target)
                   throws 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 getTarget()
Throws:
Exception - to allow pooling APIs to throw exception
See Also:
AbstractPoolingTargetSource.getTarget()

getActiveCount

public int getActiveCount()
                   throws UnsupportedOperationException
Description copied from interface: PoolingConfig
Return the number of active objects in the pool.

Specified by:
getActiveCount in interface PoolingConfig
Throws:
UnsupportedOperationException - if not supported by the pool

getIdleCount

public int getIdleCount()
                 throws UnsupportedOperationException
Description copied from interface: PoolingConfig
Return the number of idle objects in the pool.

Specified by:
getIdleCount in interface PoolingConfig
Throws:
UnsupportedOperationException - if not supported by the pool

getActive

public int getActive()
Deprecated. in favor of getActiveCount

Specified by:
getActive in interface PoolingConfig
See Also:
getActiveCount()

getFree

public int getFree()
Deprecated. in favor of getIdleCount

Specified by:
getFree in interface PoolingConfig
See Also:
getIdleCount()

destroy

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

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

makeObject

public Object makeObject()
                  throws BeansException
Specified by:
makeObject in interface PoolableObjectFactory
Throws:
BeansException

destroyObject

public void destroyObject(Object o)
                   throws Exception
Specified by:
destroyObject in interface PoolableObjectFactory
Throws:
Exception

validateObject

public boolean validateObject(Object o)
Specified by:
validateObject in interface PoolableObjectFactory

activateObject

public void activateObject(Object o)
                    throws Exception
Specified by:
activateObject in interface PoolableObjectFactory
Throws:
Exception

passivateObject

public void passivateObject(Object o)
                     throws Exception
Specified by:
passivateObject in interface PoolableObjectFactory
Throws:
Exception


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