T - the type of objects held in the concrete object poolpublic interface PoolObjectFactory<T>
| Modifier and Type | Method and Description |
|---|---|
T |
create()
Creates a new object for the calling object pool.
|
void |
destroy(T obj)
A method which will be called when an object from the object pool needs to be destroyed,
which is when the
readyToTake(T) or readyToRestore(T) methods have returned
false, or when the pool is shrinking its size (via calling reduceCreated),
or when the pool is terminating. |
boolean |
readyToRestore(T obj)
A validation/passivation hook which will be called by the
restore methods of
ConcurrentLinkedPool when an object taken
before that from the object pool is about to be restored (returned back) to the pool. |
boolean |
readyToTake(T obj)
A validation/activation hook which will be called by the
take... methods of
ConcurrentLinkedPool when an object from
the object pool is requested by the application. |
T create()
null.
This method will be called by the constructors of ConcurrentLinkedPool,
and by any of the take... methods of the before
mentioned two classes, if the take... methods were able to obtain a permit from the
counting Semaphore guarding the pool, but there was not an available and valid object
in the pool. I.e. this is the case when a new object is created (lazily) in the pool on request.
boolean readyToTake(T obj)
take... methods of
ConcurrentLinkedPool when an object from
the object pool is requested by the application. This is an optional operation
which concrete implementation may simply always return true.
If there is a particular activation or validation which needs to be done for the taken from the pool object, this is the ideal place where it can be done.
obj - an object which is taken from the object pool and which is to be given
to the calling applicationtrue if the validation/activation is successful, false otherwisereadyToRestore(T)boolean readyToRestore(T obj)
restore methods of
ConcurrentLinkedPool when an object taken
before that from the object pool is about to be restored (returned back) to the pool.
This is an optional operation which concrete implementation may simply always return
true.
If there is a particular passivation or validation which needs to be done for the restored to the pool object, this is the ideal place where it can be done.
obj - an object which has been taken before that from this object pool and which is now
to be restored to the pooltrue if the validation/passivation is successful, false otherwisereadyToTake(T)void destroy(T obj)
readyToTake(T) or readyToRestore(T) methods have returned
false, or when the pool is shrinking its size (via calling reduceCreated),
or when the pool is terminating. The simplest implementation of this method may simply
do nothing, however if there are any allocated resources associated with the to-be-destroyed
object, like network connections or similar, this is the ideal place where they can be
de-allocated.obj - an object from the pool which needs to be destroyedCopyright © 2013-2016 vibur.org. All Rights Reserved.