This class is intended to be thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private volatile CallStack | |
| private volatile long | |
| private final Instant | |
| private volatile Instant | |
| private volatile Instant | |
| private volatile Instant | |
| private volatile boolean | |
| private final T | |
| private PooledObjectState | |
| private final Clock | |
| private volatile CallStack |
| Access | Constructor and Description |
|---|---|
| public | DefaultPooledObject(final T
The object to wrap object)Creates a new instance that wraps the provided object so that the pool can track the state of the pooled object. |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized boolean | |
| public int | compareTo(final PooledObject<T> other)
Implements org. Orders instances based on idle time - i.e. the length of time since the instance was returned to the pool. |
| public synchronized boolean | deallocate()
Implements org. Deallocates the object and sets it |
| public synchronized boolean | endEvictionTest(final Deque<PooledObject<T>> idleQueue)
Implements org. Notifies the object that the eviction test has ended. |
| public long | getActiveTimeMillis()
Implements org. Gets the amount of time in milliseconds this object last spent in the active state (it may still be active in which case subsequent calls will return an increased value). |
| public long | Returns: The number of times this object has been borrowed.Overrides default org. Gets the number of times this object has been borrowed. |
| public Instant | getCreateInstant()
Overrides default org. Gets the time (using the same basis as |
| public long | getCreateTime()
Implements org. Gets the time (using the same basis as
|
| public Duration | getIdleDuration()
Overrides default org. Gets the amount of time that this object last spend in the idle state (it may still be idle in which case subsequent calls will return an increased value). |
| public Duration | getIdleTime()
Overrides default org. Gets the amount of time that this object last spend in the idle state (it may still be idle in which case subsequent calls will return an increased value). |
| public long | getIdleTimeMillis()
Implements org. Gets the amount of 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). |
| public Instant | getLastBorrowInstant()
Overrides default org. Gets the time the wrapped object was last borrowed. |
| public long | getLastBorrowTime()
Implements org. Gets the time the wrapped object was last borrowed. |
| public Instant | getLastReturnInstant()
Overrides default org. Gets the time the wrapped object was last borrowed. |
| public long | getLastReturnTime()
Implements org. Gets the time the wrapped object was last returned. |
| public Instant | Returns: the last Instant this object was used.Overrides default org. Gets an estimate of the last time this object was used. |
| public long | Returns: the last time this object was usedImplements org. Gets an estimate of the last time this object was used. |
| public T | getObject()
Implements org. Gets the underlying object that is wrapped by this instance of
|
| public synchronized PooledObjectState | Returns: stateImplements org. Gets the state of this object. |
| public synchronized void | |
| public synchronized void | markAbandoned()
Implements org. Marks the pooled object as |
| public synchronized void | markReturning()
Implements org. Marks the pooled object as |
| private Instant | |
| public void | printStackTrace(final PrintWriter writer)
Implements org. 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. |
| public void | setLogAbandoned(final boolean logAbandoned)
Implements org. Sets whether to use abandoned object tracking. |
| public void | setRequireFullStackTrace(final boolean
the new configuration setting for abandoned object
logging requireFullStackTrace)Overrides default org. Configures the stack trace generation strategy based on whether or not fully detailed stack traces are required. |
| public synchronized boolean | startEvictionTest()
Implements org. Attempts to place the pooled object in the
|
| public String | toString()
Overrides java. Implements org. Gets a String form of the wrapper for debug purposes. |
| public void | use()
Implements org. Records the current stack trace as the last time the object was used. |
| borrowedBy | back to summary |
|---|---|
| private volatile CallStack borrowedBy | |
| borrowedCount | back to summary |
|---|---|
| private volatile long borrowedCount | |
| createInstant | back to summary |
|---|---|
| private final Instant createInstant | |
| lastBorrowInstant | back to summary |
|---|---|
| private volatile Instant lastBorrowInstant | |
| lastReturnInstant | back to summary |
|---|---|
| private volatile Instant lastReturnInstant | |
| lastUseInstant | back to summary |
|---|---|
| private volatile Instant lastUseInstant | |
| logAbandoned | back to summary |
|---|---|
| private volatile boolean logAbandoned | |
| object | back to summary |
|---|---|
| private final T object | |
| state | back to summary |
|---|---|
| private PooledObjectState state | |
| systemClock | back to summary |
|---|---|
| private final Clock systemClock | |
| usedBy | back to summary |
|---|---|
| private volatile CallStack usedBy | |
| DefaultPooledObject | back to summary |
|---|---|
| public DefaultPooledObject(final T object) Creates a new instance that wraps the provided object so that the pool can track the state of the pooled object.
| |
| allocate | back to summary |
|---|---|
| public synchronized boolean allocate() Implements org. Allocates the object. | |
| compareTo | back to summary |
|---|---|
| public int compareTo(final PooledObject<T> other) Implements org. Doc from org. Orders instances based on idle time - i.e. the length of time since the instance was returned to the pool. Used by the GKOP idle object evictor. Note This class has a natural ordering that is inconsistent with equals if distinct objects have the same identity hash code. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| deallocate | back to summary |
|---|---|
| public synchronized boolean deallocate() Implements org. Deallocates the object and sets it | |
| endEvictionTest | back to summary |
|---|---|
| public synchronized boolean endEvictionTest(final Deque<PooledObject<T>> idleQueue) Implements org. Doc from org. Notifies the object that the eviction test has ended.
| |
| getActiveTimeMillis | back to summary |
|---|---|
| public long getActiveTimeMillis() Implements org. Doc from org. Gets the amount of time in milliseconds this object last spent in the active state (it may still be active in which case subsequent calls will return an increased value).
| |
| getBorrowedCount | back to summary |
|---|---|
| public long getBorrowedCount() Overrides default org. Gets the number of times this object has been borrowed.
| |
| getCreateInstant | back to summary |
|---|---|
| public Instant getCreateInstant() Overrides default org. Doc from org. Gets the time (using the same basis as
| |
| getCreateTime | back to summary |
|---|---|
| public long getCreateTime() Implements org. Doc from org. Gets the time (using the same basis as
| |
| getIdleDuration | back to summary |
|---|---|
| public Duration getIdleDuration() Overrides default org. Doc from org. Gets the amount of time that this object last spend in the idle state (it may still be idle in which case subsequent calls will return an increased value).
| |
| getIdleTime | back to summary |
|---|---|
| public Duration getIdleTime() Overrides default org. Doc from org. Gets the amount of time that this object last spend in the idle state (it may still be idle in which case subsequent calls will return an increased value).
| |
| getIdleTimeMillis | back to summary |
|---|---|
| public long getIdleTimeMillis() Implements org. Doc from org. Gets the amount of 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).
| |
| getLastBorrowInstant | back to summary |
|---|---|
| public Instant getLastBorrowInstant() Overrides default org. Doc from org. Gets the time the wrapped object was last borrowed.
| |
| getLastBorrowTime | back to summary |
|---|---|
| public long getLastBorrowTime() Implements org. Doc from org. Gets the time the wrapped object was last borrowed.
| |
| getLastReturnInstant | back to summary |
|---|---|
| public Instant getLastReturnInstant() Overrides default org. Doc from org. Gets the time the wrapped object was last borrowed.
| |
| getLastReturnTime | back to summary |
|---|---|
| public long getLastReturnTime() Implements org. Doc from org. Gets the time the wrapped object was last returned.
| |
| getLastUsedInstant | back to summary |
|---|---|
| public Instant getLastUsedInstant() Overrides default org. Gets an estimate of the last time this object was used. If the class
of the pooled object implements | |
| getLastUsedTime | back to summary |
|---|---|
| public long getLastUsedTime() Implements org. Gets an estimate of the last time this object was used. If the class
of the pooled object implements
| |
| getObject | back to summary |
|---|---|
| public T getObject() Implements org. Doc from org. Gets the underlying object that is wrapped by this instance of
| |
| getState | back to summary |
|---|---|
| public synchronized PooledObjectState getState() Implements org. Gets the state of this object.
| |
| invalidate | back to summary |
|---|---|
| public synchronized void invalidate() Implements org. Sets the state to
| |
| markAbandoned | back to summary |
|---|---|
| public synchronized void markAbandoned() Implements org. Marks the pooled object as
| |
| markReturning | back to summary |
|---|---|
| public synchronized void markReturning() Implements org. Marks the pooled object as
| |
| now | back to summary |
|---|---|
| private Instant now() Gets the current instant of the clock.
| |
| printStackTrace | back to summary |
|---|---|
| public void printStackTrace(final PrintWriter writer) Implements org. Doc from org. 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.
| |
| setLogAbandoned | back to summary |
|---|---|
| public void setLogAbandoned(final boolean logAbandoned) Implements org. Doc from org. Sets whether to use abandoned object tracking. If this is true the implementation will need to record the stack trace of the last caller to borrow this object.
| |
| setRequireFullStackTrace | back to summary |
|---|---|
| public void setRequireFullStackTrace(final boolean requireFullStackTrace) Overrides default org. Configures the stack trace generation strategy based on whether or not fully detailed stack traces are required. When set to false, abandoned logs may only include caller class information rather than method names, line numbers, and other normal metadata available in a full stack trace.
| |
| startEvictionTest | back to summary |
|---|---|
| public synchronized boolean startEvictionTest() Implements org. Doc from org. Attempts to place the pooled object in the
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements org. Doc from org. Gets a String form of the wrapper for debug purposes. The format is not fixed and may change at any time.
| |
| use | back to summary |
|---|---|
| public void use() Implements org. Doc from org. Records the current stack trace as the last time the object was used.
| |