T
- the type of object in the poolpublic interface PooledObject<T> extends java.lang.Comparable<PooledObject<T>>
Implementations of this class are required to be thread-safe.
Modifier and Type | Method and Description |
---|---|
boolean |
allocate()
Allocates the object.
|
int |
compareTo(PooledObject<T> other)
Orders instances based on idle time - i.e. the length of time since the
instance was returned to the pool.
|
boolean |
deallocate()
|
boolean |
endEvictionTest(java.util.Deque<PooledObject<T>> idleQueue)
Called to inform the object that the eviction test has ended.
|
boolean |
equals(java.lang.Object obj) |
long |
getActiveTimeMillis()
Obtains the time in milliseconds that this object last spent in the
active state (it may still be active in which case subsequent calls will
return an increased value).
|
long |
getCreateTime()
Obtains the time (using the same basis as
System.currentTimeMillis() ) that this object was created. |
long |
getIdleTimeMillis()
Obtains the time in milliseconds that this object last spend in the
idle state (it may still be idle in which case subsequent calls will
return an increased value).
|
long |
getLastBorrowTime()
Obtains the time the wrapped object was last borrowed.
|
long |
getLastReturnTime()
Obtains the time the wrapped object was last returned.
|
long |
getLastUsedTime()
Returns an estimate of the last time this object was used.
|
T |
getObject()
Obtains the underlying object that is wrapped by this instance of
PooledObject . |
PooledObjectState |
getState()
Returns the state of this object.
|
int |
hashCode() |
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(java.io.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?
|
boolean |
startEvictionTest()
Attempts to place the pooled object in the
PooledObjectState.EVICTION state. |
java.lang.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.
|
T getObject()
PooledObject
.long getCreateTime()
System.currentTimeMillis()
) that this object was created.long getActiveTimeMillis()
long getIdleTimeMillis()
long getLastBorrowTime()
long getLastReturnTime()
long getLastUsedTime()
TrackedUse
, what is returned is
the maximum of TrackedUse.getLastUsed()
and
getLastBorrowTime()
; otherwise this method gives the same
value as getLastBorrowTime()
.int compareTo(PooledObject<T> other)
Note: This class has a natural ordering that is inconsistent with equals if distinct objects have the same identity hash code.
compareTo
in interface java.lang.Comparable<PooledObject<T>>
boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
int hashCode()
hashCode
in class java.lang.Object
java.lang.String toString()
toString
in class java.lang.Object
boolean startEvictionTest()
PooledObjectState.EVICTION
state.true
if the object was placed in the
PooledObjectState.EVICTION
state otherwise
false
boolean endEvictionTest(java.util.Deque<PooledObject<T>> idleQueue)
idleQueue
- The queue of idle objects to which the object should be
returnedboolean allocate()
true
if the original state was IDLE
boolean deallocate()
true
if the state was ALLOCATED
void invalidate()
INVALID
void setLogAbandoned(boolean logAbandoned)
logAbandoned
- The new configuration setting for abandoned
object trackingvoid use()
void printStackTrace(java.io.PrintWriter writer)
writer
- The destination for the debug outputPooledObjectState getState()
void markAbandoned()
void markReturning()
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.