K- the type of keys in this pool
V- the type of objects held in this pool
public interface KeyedPoolableObjectFactory<K,V>
makeObjectis called whenever a new instance is needed.
activateObjectis invoked on every instance that has been
passivatedbefore it is
borrowedfrom the pool.
validateObjectis invoked on
activatedinstances to make sure they can be
borrowedfrom the pool.
validateObjectmay also be used to test an instance being
returnedto the pool before it is
passivated. It will only be invoked on an activated instance.
passivateObjectis invoked on every instance when it is returned to the pool.
destroyObjectis invoked on every instance when it is being "dropped" from the pool (whether due to the response from
validateObject, or for reasons specific to the pool implementation.) There is no guarantee that the instance being destroyed will be considered active, passive or in a generally consistent state.
KeyedPoolableObjectFactory must be thread-safe. The only promise
KeyedObjectPool makes is that the same instance of an object will not
be passed to more than one method of a
at a time.
|Modifier and Type||Method and Description|
Reinitialize an instance to be returned by the pool.
Destroy an instance no longer needed by the pool.
Create an instance that can be served by the pool.
Uninitialize an instance to be returned to the idle object pool.
Ensures that the instance is safe to be returned by the pool.
V makeObject(K key) throws Exception
key- the key used when constructing the object
Exception- if there is a problem creating a new instance, this will be propagated to the code requesting an object.
void destroyObject(K key, V obj) throws Exception
It is important for implementations of this method to be aware
that there is no guarantee about what state
will be in and the implementation should be prepared to handle
Also, an implementation must take in to consideration that instances lost to the garbage collector may never be destroyed.
boolean validateObject(K key, V obj)
objshould be destroyed.
key- the key used when selecting the object
obj- the instance to be validated
objis not valid and should be dropped from the pool,
void activateObject(K key, V obj) throws Exception
void passivateObject(K key, V obj) throws Exception
Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.