public abstract class AbstractObjectWrapper<T,E extends java.lang.Exception>
extends java.lang.Object
ObjectWrapperLifeCycle| Modifier | Constructor and Description |
|---|---|
protected |
AbstractObjectWrapper(ObjectPool<T,E> objectPool,
T pooledObject)
Constructs a new
AbstractObjectWrapper for the given object and
pool. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_checkIn()
Checks the wrapped object back into the object pool.
|
protected void |
_ensureIsValid()
Simply returns if the wrapper is still valid and throws an
IllegalStateException if it isn't. |
long |
_getLastActiveTime()
Returns the last active time, i.e. the last time the wrapped object was used
by the borrower.
|
protected T |
_getObject()
Returns the wrapped object or throws an
IllegalStateException if
the wrapper has already been invalidated. |
protected void |
_invalidate()
Invalidates this wrapper, i.e. references to the wrapped object and the object pool
are discarded.
|
protected boolean |
_isValid()
Returns whether this wrapper is still valid.
|
protected void |
_updateLastActiveTime()
Updates the
last active time to the current system
time. |
protected AbstractObjectWrapper(ObjectPool<T,E> objectPool, T pooledObject)
AbstractObjectWrapper for the given object and
pool.objectPool - the object to be wrappedpooledObject - the pool responsible for the given objectprotected T _getObject() throws E extends java.lang.Exception
IllegalStateException if
the wrapper has already been invalidated.
This method is intended to be called in subclasses to implement the
delegating methods. It will update the _getLastActiveTime() last
active time} to the current system time and - as already mentioned - it
will fail if the wrapper was invalidated.
In subclasses, this method will have to be overridden with a simple call to
its super implementation in order to provide access to the implementation
of ObjectWrapperLifeCycle.unwrap(Object).
E - not thrown by this implementation, but may be thrown in sub
classes if _ensureIsValid() is implemented differentlyE extends java.lang.Exceptionprotected void _ensureIsValid()
throws E extends java.lang.Exception
IllegalStateException if it isn't. May be overridden in subclasses to
either throw the same exception type with a different message or a
domain-specific exception.java.lang.IllegalStateException - if the wrapper has been invalidated (may
change of overridden)E - not thrown by this implementation, but may be thrown in sub
classesE extends java.lang.Exceptionprotected boolean _isValid()
_getObject() will raise an IllegalStateException.
Please note that this does in no way indicate whether the wrapped object is still valid!
protected void _invalidate()
_getObject() will fail!
In subclasses, this method will have to be overridden with a simple call to its super
implementation in order to provide access to the implementation of ObjectWrapperLifeCycle.invalidate(Object).
protected void _checkIn()
throws E extends java.lang.Exception
E - passed through exception from ObjectPool.checkIn(Object)E extends java.lang.Exceptionpublic long _getLastActiveTime()
_getObject()
is called.
This method may be overridden to fetch this information directly from the wrapped object.
protected void _updateLastActiveTime()
last active time to the current system
time. This method is implicitly called by _getObject().