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 Object
implements KeyedPoolableObjectFactory<K,V>
A base implementation of
KeyedPoolableObjectFactory
.
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateObject
(K key, V obj) Reinitialize an instance to be returned by the pool.void
destroyObject
(K key, V obj) Destroy an instance no longer needed by the pool.abstract V
makeObject
(K key) Create an instance that can be served by the pool.void
passivateObject
(K key, V obj) Uninitialize an instance to be returned to the idle object pool.boolean
validateObject
(K key, V obj) Ensures that the instance is safe to be returned by the pool.
-
Constructor Details
-
BaseKeyedPoolableObjectFactory
public BaseKeyedPoolableObjectFactory()
-
-
Method Details
-
makeObject
Create an instance that can be served by the pool.- Specified by:
makeObject
in interfaceKeyedPoolableObjectFactory<K,
V> - Parameters:
key
- the key used when constructing the object- Returns:
- an instance that can be served by the pool
- Throws:
Exception
- if there is a problem creating a new instance, this will be propagated to the code requesting an object.
-
destroyObject
Destroy an instance no longer needed by the pool.The default implementation is a no-op.
- Specified by:
destroyObject
in interfaceKeyedPoolableObjectFactory<K,
V> - Parameters:
key
- the key used when selecting the instanceobj
- the instance to be destroyed- Throws:
Exception
- should be avoided as it may be swallowed by the pool implementation.- See Also:
-
validateObject
Ensures that the instance is safe to be returned by the pool.The default implementation always returns true.
- Specified by:
validateObject
in interfaceKeyedPoolableObjectFactory<K,
V> - Parameters:
key
- the key used when selecting the objectobj
- the instance to be validated- Returns:
- always
true
in the default implementation
-
activateObject
Reinitialize an instance to be returned by the pool.The default implementation is a no-op.
- Specified by:
activateObject
in interfaceKeyedPoolableObjectFactory<K,
V> - Parameters:
key
- the key used when selecting the objectobj
- the instance to be activated- Throws:
Exception
- if there is a problem activatingobj
, this exception may be swallowed by the pool.- See Also:
-
passivateObject
Uninitialize an instance to be returned to the idle object pool.The default implementation is a no-op.
- Specified by:
passivateObject
in interfaceKeyedPoolableObjectFactory<K,
V> - Parameters:
key
- the key used when selecting the objectobj
- the instance to be passivated- Throws:
Exception
- if there is a problem passivatingobj
, this exception may be swallowed by the pool.- See Also:
-