Package org.apache.commons.pool
Class BaseKeyedPoolableObjectFactory<K,V>
- java.lang.Object
-
- org.apache.commons.pool.BaseKeyedPoolableObjectFactory<K,V>
-
- Type Parameters:
K- the type of keys in this poolV- the type of objects held in this pool
- All Implemented Interfaces:
KeyedPoolableObjectFactory<K,V>
public abstract class BaseKeyedPoolableObjectFactory<K,V> extends java.lang.Object implements KeyedPoolableObjectFactory<K,V>
A base implementation ofKeyedPoolableObjectFactory.All operations defined here are essentially no-op's.
- Since:
- Pool 1.0
- Version:
- $Revision: 1222388 $ $Date: 2011-12-22 13:28:27 -0500 (Thu, 22 Dec 2011) $
- Author:
- Rodney Waldhoff
- See Also:
KeyedPoolableObjectFactory
-
-
Constructor Summary
Constructors Constructor Description BaseKeyedPoolableObjectFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidactivateObject(K key, V obj)Reinitialize an instance to be returned by the pool.voiddestroyObject(K key, V obj)Destroy an instance no longer needed by the pool.abstract VmakeObject(K key)Create an instance that can be served by the pool.voidpassivateObject(K key, V obj)Uninitialize an instance to be returned to the idle object pool.booleanvalidateObject(K key, V obj)Ensures that the instance is safe to be returned by the pool.
-
-
-
Method Detail
-
makeObject
public abstract V makeObject(K key) throws java.lang.Exception
Create an instance that can be served by the pool.- Specified by:
makeObjectin interfaceKeyedPoolableObjectFactory<K,V>- Parameters:
key- the key used when constructing the object- Returns:
- an instance that can be served by the pool
- Throws:
java.lang.Exception- if there is a problem creating a new instance, this will be propagated to the code requesting an object.
-
destroyObject
public void destroyObject(K key, V obj) throws java.lang.Exception
Destroy an instance no longer needed by the pool.The default implementation is a no-op.
- Specified by:
destroyObjectin interfaceKeyedPoolableObjectFactory<K,V>- Parameters:
key- the key used when selecting the instanceobj- the instance to be destroyed- Throws:
java.lang.Exception- should be avoided as it may be swallowed by the pool implementation.- See Also:
KeyedPoolableObjectFactory.validateObject(K, V),KeyedObjectPool.invalidateObject(K, V)
-
validateObject
public boolean validateObject(K key, V obj)
Ensures that the instance is safe to be returned by the pool.The default implementation always returns true.
- Specified by:
validateObjectin interfaceKeyedPoolableObjectFactory<K,V>- Parameters:
key- the key used when selecting the objectobj- the instance to be validated- Returns:
- always
truein the default implementation
-
activateObject
public void activateObject(K key, V obj) throws java.lang.Exception
Reinitialize an instance to be returned by the pool.The default implementation is a no-op.
- Specified by:
activateObjectin interfaceKeyedPoolableObjectFactory<K,V>- Parameters:
key- the key used when selecting the objectobj- the instance to be activated- Throws:
java.lang.Exception- if there is a problem activatingobj, this exception may be swallowed by the pool.- See Also:
KeyedPoolableObjectFactory.destroyObject(K, V)
-
passivateObject
public void passivateObject(K key, V obj) throws java.lang.Exception
Uninitialize an instance to be returned to the idle object pool.The default implementation is a no-op.
- Specified by:
passivateObjectin interfaceKeyedPoolableObjectFactory<K,V>- Parameters:
key- the key used when selecting the objectobj- the instance to be passivated- Throws:
java.lang.Exception- if there is a problem passivatingobj, this exception may be swallowed by the pool.- See Also:
KeyedPoolableObjectFactory.destroyObject(K, V)
-
-