Top Description Constructors Methods
org.apache.commons.pool2

public abstract Class BaseKeyedPooledObjectFactory<K, V>

extends BaseObject
implements KeyedPooledObjectFactory<K, V>
Class Inheritance
All Implemented Interfaces
org.apache.commons.pool2.KeyedPooledObjectFactory
Type Parameters
<K>
The type of keys managed by this factory.
<V>
Type of element managed by this factory.
Imports
java.util.Objects

A base implementation of KeyedPooledObjectFactory.

All operations defined here are essentially no-op's.

This class is immutable, and therefore thread-safe.

Since
2.0
See Also
KeyedPooledObjectFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
activateObject(final K
the key used when selecting the object
key
,
final PooledObject<V>
a PooledObject wrapping the instance to be activated
p
)

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.activateObject.

Reinitializes an instance to be returned by the pool.
public abstract V

Returns:

an instance that can be served by the pool
create
(K
the key used when constructing the object
key
)

Creates an instance that can be served by the pool.

public void
destroyObject(final K
the key used when selecting the instance
key
,
final PooledObject<V>
a PooledObject wrapping the instance to be destroyed
p
)

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.destroyObject.

Destroys an instance no longer needed by the pool.
public PooledObject<V>
makeObject(final K
the key used when constructing the object
key
)

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.makeObject.

Creates an instance that can be served by the pool and wrap it in a PooledObject to be managed by the pool.
public void
passivateObject(final K
the key used when selecting the object
key
,
final PooledObject<V>
a PooledObject wrapping the instance to be passivated
p
)

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.passivateObject.

Uninitializes an instance to be returned to the idle object pool.
public boolean

Returns:

always true in this default implementation
validateObject
(final K
the key used when selecting the object
key
,
final PooledObject<V>
a PooledObject wrapping the instance to be validated
p
)

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.validateObject.

Ensures that the instance is safe to be returned by the pool.
public abstract PooledObject<V>

Returns:

The provided instance, wrapped by a PooledObject
wrap
(V
the instance to wrap, should not be null.
value
)

Wraps the provided instance with an implementation of PooledObject.

Inherited from org.apache.commons.pool2.BaseObject:
toStringtoStringAppendFields

Constructor Detail

BaseKeyedPooledObjectFactoryback to summary
public BaseKeyedPooledObjectFactory()

Method Detail

activateObjectback to summary
public void activateObject(final K key, final PooledObject<V> p) throws Exception

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.activateObject.

Reinitializes an instance to be returned by the pool.

The default implementation is a no-op.

Parameters
key:K

the key used when selecting the object

p:PooledObject<V>

a PooledObject wrapping the instance to be activated

Annotations
@Override
Exceptions
Exception:

Doc from org.apache.commons.pool2.KeyedPooledObjectFactory.activateObject.

if there is a problem activating obj, this exception may be swallowed by the pool.

createback to summary
public abstract V create(K key) throws Exception

Creates an instance that can be served by the pool.

Parameters
key:K

the key used when constructing the object

Returns:V

an instance that can be served by the pool

Exceptions
Exception:
if there is a problem creating a new instance, this will be propagated to the code requesting an object.
destroyObjectback to summary
public void destroyObject(final K key, final PooledObject<V> p) throws Exception

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.destroyObject.

Destroys an instance no longer needed by the pool.

The default implementation is a no-op.

Parameters
key:K

the key used when selecting the instance

p:PooledObject<V>

a PooledObject wrapping the instance to be destroyed

Annotations
@Override
Exceptions
Exception:

Doc from org.apache.commons.pool2.KeyedPooledObjectFactory.destroyObject.

should be avoided as it may be swallowed by the pool implementation.

makeObjectback to summary
public PooledObject<V> makeObject(final K key) throws Exception

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.makeObject.

Doc from org.apache.commons.pool2.KeyedPooledObjectFactory.makeObject.

Creates an instance that can be served by the pool and wrap it in a PooledObject to be managed by the pool.

Parameters
key:K

the key used when constructing the object

Returns:PooledObject<V>

a PooledObject wrapping an instance that can be served by the pool.

Annotations
@Override
Exceptions
Exception:
if there is a problem creating a new instance, this will be propagated to the code requesting an object.
passivateObjectback to summary
public void passivateObject(final K key, final PooledObject<V> p) throws Exception

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.passivateObject.

Uninitializes an instance to be returned to the idle object pool.

The default implementation is a no-op.

Parameters
key:K

the key used when selecting the object

p:PooledObject<V>

a PooledObject wrapping the instance to be passivated

Annotations
@Override
Exceptions
Exception:

Doc from org.apache.commons.pool2.KeyedPooledObjectFactory.passivateObject.

if there is a problem passivating obj, this exception may be swallowed by the pool.

validateObjectback to summary
public boolean validateObject(final K key, final PooledObject<V> p)

Implements org.apache.commons.pool2.KeyedPooledObjectFactory.validateObject.

Ensures that the instance is safe to be returned by the pool.

The default implementation always returns true.

Parameters
key:K

the key used when selecting the object

p:PooledObject<V>

a PooledObject wrapping the instance to be validated

Returns:boolean

always true in this default implementation

Annotations
@Override
wrapback to summary
public abstract PooledObject<V> wrap(V value)

Wraps the provided instance with an implementation of PooledObject.

Parameters
value:V

the instance to wrap, should not be null.

Returns:PooledObject<V>

The provided instance, wrapped by a PooledObject