nf.fr.eraasoft.pool
Class PoolableObjectBase<T>
java.lang.Object
nf.fr.eraasoft.pool.PoolableObjectBase<T>
- Type Parameters:
T -
- All Implemented Interfaces:
- PoolableObject<T>
public abstract class PoolableObjectBase<T>
- extends java.lang.Object
- implements PoolableObject<T>
Utility class to create a PoolableObject.
Just implement PoolableObject.make and activate method
A sample :
PoolableObject<StringBuilder> poolableStringBuilder = new PoolableObjectBase<StringBuilder>() {
public StringBuilder make() throws PoolException {
return new StringBuilder();
}
public void activate(StringBuilder t) throws PoolException {
t.setLength(0);
}
};
- Author:
- eddie
- See Also:
PoolableObject
|
Method Summary |
void |
destroy(T t)
is 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.) |
void |
passivate(T t)
is invoked on every instance when it is returned to the pool. |
boolean |
validate(T t)
is invoked on activated instances to make sure they can be borrowed from
the pool. validateObject may also be used to test an instance being
returned to the pool before it is passivated. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PoolableObjectBase
public PoolableObjectBase()
validate
public boolean validate(T t)
- Description copied from interface:
PoolableObject
- is invoked on activated instances to make sure they can be borrowed from
the pool. validateObject may also be used to test an instance being
returned to the pool before it is passivated. It will only be invoked on
an activated instance.
- Specified by:
validate in interface PoolableObject<T>
- Returns:
destroy
public void destroy(T t)
- Description copied from interface:
PoolableObject
- is 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.
- Specified by:
destroy in interface PoolableObject<T>
passivate
public void passivate(T t)
- Description copied from interface:
PoolableObject
- is invoked on every instance when it is returned to the pool.
- Specified by:
passivate in interface PoolableObject<T>
Copyright © 2013. All Rights Reserved.