public interface PoolableObjectFactory<K,V>
ObjectPool
By contract, when an ObjectPool delegates to a PoolableObjectFactory,
createObject is called whenever a new instance is needed.
validateObject is invoked for making sure
they can be borrowed or returned from the pool.
destroyObject is invoked on every instance when it is being "dropped" from the pool.| Modifier and Type | Method and Description |
|---|---|
V |
createObject(K key)
Create an instance that can be served by the pool
|
void |
destroyObject(K key,
V value)
Destroy an instance no longer needed by the pool
|
boolean |
validateObject(K key,
V value)
Ensures that the instance is safe to be borrowed and returned by the pool
|
V createObject(K key) throws Exception
key - the key used when constructing the objectException - if there is a problem creating a new instancevoid destroyObject(K key, V value) throws Exception
key - the key used when selecting the instancevalue - the instance to be destroyedException - if there is a problem destroying valueboolean validateObject(K key, V value) throws Exception
key - the key used when selecting the objectvalue - the instance to be validatedvalue is not valid and should be dropped from the pool,
true otherwiseException - if there is a problem validating value.
an exception should be avoided as it may be swallowed by the pool implementation.Copyright © 2020. All rights reserved.