Package org.apache.commons.pool
Class PoolUtils.PoolableObjectFactoryAdaptor<K,V>
java.lang.Object
org.apache.commons.pool.PoolUtils.PoolableObjectFactoryAdaptor<K,V>
- All Implemented Interfaces:
PoolableObjectFactory<V>
- Enclosing class:
PoolUtils
private static class PoolUtils.PoolableObjectFactoryAdaptor<K,V>
extends Object
implements PoolableObjectFactory<V>
Adaptor class that wraps and converts a KeyedPoolableObjectFactory with a fixed
key to a PoolableObjectFactory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final KFixed keyprivate final KeyedPoolableObjectFactory<K, V> Wrapped factory -
Constructor Summary
ConstructorsConstructorDescriptionPoolableObjectFactoryAdaptor(KeyedPoolableObjectFactory<K, V> keyedFactory, K key) Create a PoolableObjectFactoryAdaptor wrapping the provided KeyedPoolableObjectFactory with the given fixed key. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivateObject(V obj) Activate the object, passing the fixed key to the factory.voiddestroyObject(V obj) Destroy the object, passing the fixed key to the factory.Create an object instance using the configured factory and key.voidpassivateObject(V obj) Passivate the object, passing the fixed key to the factory.toString()booleanvalidateObject(V obj) Validate the object, passing the fixed key to the factory.
-
Field Details
-
key
Fixed key -
keyedFactory
Wrapped factory
-
-
Constructor Details
-
PoolableObjectFactoryAdaptor
PoolableObjectFactoryAdaptor(KeyedPoolableObjectFactory<K, V> keyedFactory, K key) throws IllegalArgumentExceptionCreate a PoolableObjectFactoryAdaptor wrapping the provided KeyedPoolableObjectFactory with the given fixed key.- Parameters:
keyedFactory- KeyedPoolableObjectFactory that will manage objectskey- fixed key- Throws:
IllegalArgumentException- if either of the parameters is null
-
-
Method Details
-
makeObject
Create an object instance using the configured factory and key.- Specified by:
makeObjectin interfacePoolableObjectFactory<K>- Returns:
- new object instance
- Throws:
Exception- if there is a problem creating a new instance, this will be propagated to the code requesting an object.
-
destroyObject
Destroy the object, passing the fixed key to the factory.- Specified by:
destroyObjectin interfacePoolableObjectFactory<K>- Parameters:
obj- object to destroy- Throws:
Exception- should be avoided as it may be swallowed by the pool implementation.- See Also:
-
validateObject
Validate the object, passing the fixed key to the factory.- Specified by:
validateObjectin interfacePoolableObjectFactory<K>- Parameters:
obj- object to validate- Returns:
- true if validation is successful
-
activateObject
Activate the object, passing the fixed key to the factory.- Specified by:
activateObjectin interfacePoolableObjectFactory<K>- Parameters:
obj- object to activate- Throws:
Exception- if there is a problem activatingobj, this exception may be swallowed by the pool.- See Also:
-
passivateObject
Passivate the object, passing the fixed key to the factory.- Specified by:
passivateObjectin interfacePoolableObjectFactory<K>- Parameters:
obj- object to passivate- Throws:
Exception- if there is a problem passivatingobj, this exception may be swallowed by the pool.- See Also:
-
toString
-