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 java.lang.Object implements PoolableObjectFactory<V>
Adaptor class that wraps and converts a KeyedPoolableObjectFactory with a fixed key to a PoolableObjectFactory.
-
-
Field Summary
Fields Modifier and Type Field Description private KkeyFixed keyprivate KeyedPoolableObjectFactory<K,V>keyedFactoryWrapped factory
-
Constructor Summary
Constructors Constructor Description PoolableObjectFactoryAdaptor(KeyedPoolableObjectFactory<K,V> keyedFactory, K key)Create a PoolableObjectFactoryAdaptor wrapping the provided KeyedPoolableObjectFactory with the given fixed key.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateObject(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.VmakeObject()Create an object instance using the configured factory and key.voidpassivateObject(V obj)Passivate the object, passing the fixed key to the factory.java.lang.StringtoString()booleanvalidateObject(V obj)Validate the object, passing the fixed key to the factory.
-
-
-
Field Detail
-
key
private final K key
Fixed key
-
keyedFactory
private final KeyedPoolableObjectFactory<K,V> keyedFactory
Wrapped factory
-
-
Constructor Detail
-
PoolableObjectFactoryAdaptor
PoolableObjectFactoryAdaptor(KeyedPoolableObjectFactory<K,V> keyedFactory, K key) throws java.lang.IllegalArgumentException
Create a PoolableObjectFactoryAdaptor wrapping the provided KeyedPoolableObjectFactory with the given fixed key.- Parameters:
keyedFactory- KeyedPoolableObjectFactory that will manage objectskey- fixed key- Throws:
java.lang.IllegalArgumentException- if either of the parameters is null
-
-
Method Detail
-
makeObject
public V makeObject() throws java.lang.Exception
Create an object instance using the configured factory and key.- Specified by:
makeObjectin interfacePoolableObjectFactory<K>- Returns:
- new object instance
- 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(V obj) throws java.lang.Exception
Destroy the object, passing the fixed key to the factory.- Specified by:
destroyObjectin interfacePoolableObjectFactory<K>- Parameters:
obj- object to destroy- Throws:
java.lang.Exception- should be avoided as it may be swallowed by the pool implementation.- See Also:
PoolableObjectFactory.validateObject(T),ObjectPool.invalidateObject(T)
-
validateObject
public boolean validateObject(V obj)
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
public void activateObject(V obj) throws java.lang.Exception
Activate the object, passing the fixed key to the factory.- Specified by:
activateObjectin interfacePoolableObjectFactory<K>- Parameters:
obj- object to activate- Throws:
java.lang.Exception- if there is a problem activatingobj, this exception may be swallowed by the pool.- See Also:
PoolableObjectFactory.destroyObject(T)
-
passivateObject
public void passivateObject(V obj) throws java.lang.Exception
Passivate the object, passing the fixed key to the factory.- Specified by:
passivateObjectin interfacePoolableObjectFactory<K>- Parameters:
obj- object to passivate- Throws:
java.lang.Exception- if there is a problem passivatingobj, this exception may be swallowed by the pool.- See Also:
PoolableObjectFactory.destroyObject(T)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-