|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.pool2.impl.DefaultPooledObject<T>
T
- the type of object in the poolpublic class DefaultPooledObject<T>
This wrapper is used to track the additional information, such as state, for the pooled objects.
This class is intended to be thread-safe.
Constructor Summary | |
---|---|
DefaultPooledObject(T object)
Create a new instance that wraps the provided object so that the pool can track the state of the pooled object. |
Method Summary | |
---|---|
boolean |
allocate()
Allocates the object. |
int |
compareTo(PooledObject<T> other)
Orders instances based on idle time - i.e. |
boolean |
deallocate()
Deallocates the object and sets it IDLE
if it is currently ALLOCATED . |
boolean |
endEvictionTest(Deque<PooledObject<T>> idleQueue)
Called to inform the object that the eviction test has ended. |
long |
getActiveTimeMillis()
Obtain the time in milliseconds that this object last spent in the the active state (it may still be active in which case subsequent calls will return an increased value). |
long |
getCreateTime()
Obtain the time (using the same basis as System.currentTimeMillis() ) that this object was created. |
long |
getIdleTimeMillis()
Obtain the time in milliseconds that this object last spend in the the idle state (it may still be idle in which case subsequent calls will return an increased value). |
long |
getLastBorrowTime()
Obtain the time the wrapped object was last borrowed. |
long |
getLastReturnTime()
Obtain the time the wrapped object was last returned. |
long |
getLastUsedTime()
Return an estimate of the last time this object was used. |
T |
getObject()
Obtain the underlying object that is wrapped by this instance of PooledObject . |
PooledObjectState |
getState()
Returns the state of this object. |
void |
invalidate()
Sets the state to INVALID |
void |
markAbandoned()
Marks the pooled object as abandoned. |
void |
markReturning()
Marks the object as returning to the pool. |
void |
printStackTrace(PrintWriter writer)
Prints the stack trace of the code that borrowed this pooled object and the stack trace of the last code to use this object (if available) to the supplied writer. |
void |
setLogAbandoned(boolean logAbandoned)
Is abandoned object tracking being used? If this is true the implementation will need to record the stack trace of the last caller to borrow this object. |
boolean |
startEvictionTest()
Attempt to place the pooled object in the PooledObjectState.EVICTION state. |
String |
toString()
Provides a String form of the wrapper for debug purposes. |
void |
use()
Record the current stack trace as the last time the object was used. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.commons.pool2.PooledObject |
---|
equals, hashCode |
Constructor Detail |
---|
public DefaultPooledObject(T object)
object
- The object to wrapMethod Detail |
---|
public T getObject()
PooledObject
PooledObject
.
getObject
in interface PooledObject<T>
public long getCreateTime()
PooledObject
System.currentTimeMillis()
) that this object was created.
getCreateTime
in interface PooledObject<T>
public long getActiveTimeMillis()
PooledObject
getActiveTimeMillis
in interface PooledObject<T>
public long getIdleTimeMillis()
PooledObject
getIdleTimeMillis
in interface PooledObject<T>
public long getLastBorrowTime()
PooledObject
getLastBorrowTime
in interface PooledObject<T>
public long getLastReturnTime()
PooledObject
getLastReturnTime
in interface PooledObject<T>
public long getLastUsedTime()
TrackedUse
, what is returned is
the maximum of TrackedUse.getLastUsed()
and
getLastBorrowTime()
; otherwise this method gives the same
value as getLastBorrowTime()
.
getLastUsedTime
in interface PooledObject<T>
public int compareTo(PooledObject<T> other)
PooledObject
Note: This class has a natural ordering that is inconsistent with equals if distinct objects have the same identity hash code.
compareTo
in interface Comparable<PooledObject<T>>
compareTo
in interface PooledObject<T>
public String toString()
PooledObject
toString
in interface PooledObject<T>
toString
in class Object
public boolean startEvictionTest()
PooledObject
PooledObjectState.EVICTION
state.
startEvictionTest
in interface PooledObject<T>
true
if the object was placed in the
PooledObjectState.EVICTION
state otherwise
false
public boolean endEvictionTest(Deque<PooledObject<T>> idleQueue)
PooledObject
endEvictionTest
in interface PooledObject<T>
idleQueue
- The queue if idle objects to which the object should be
returned
public boolean allocate()
allocate
in interface PooledObject<T>
true
if the original state was IDLE
public boolean deallocate()
IDLE
if it is currently ALLOCATED
.
deallocate
in interface PooledObject<T>
true
if the state was ALLOCATED
public void invalidate()
INVALID
invalidate
in interface PooledObject<T>
public void use()
PooledObject
use
in interface PooledObject<T>
public void printStackTrace(PrintWriter writer)
PooledObject
printStackTrace
in interface PooledObject<T>
writer
- The destination for the debug outputpublic PooledObjectState getState()
getState
in interface PooledObject<T>
public void markAbandoned()
markAbandoned
in interface PooledObject<T>
public void markReturning()
markReturning
in interface PooledObject<T>
public void setLogAbandoned(boolean logAbandoned)
PooledObject
setLogAbandoned
in interface PooledObject<T>
logAbandoned
- The new configuration setting for abandoned
object tracking
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |