Package org.apache.commons.dbcp2
Class AbandonedTrace
java.lang.Object
org.apache.commons.dbcp2.AbandonedTrace
- All Implemented Interfaces:
AutoCloseable,org.apache.commons.pool2.TrackedUse
- Direct Known Subclasses:
DelegatingConnection,DelegatingResultSet,DelegatingStatement
public class AbandonedTrace
extends Object
implements org.apache.commons.pool2.TrackedUse, AutoCloseable
Tracks connection usage for recovering and reporting abandoned connections.
The JDBC Connection, Statement, and ResultSet classes extend this class.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate InstantLast time this connection was used.private final List<WeakReference<AbandonedTrace>> A list of objects created by children of this object. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new AbandonedTrace without config and without doing abandoned tracing.AbandonedTrace(AbandonedTrace parent) Constructs a new AbandonedTrace with a parent object. -
Method Summary
Modifier and TypeMethodDescription(package private) static voidadd(AbandonedTrace receiver, AbandonedTrace trace) protected voidaddTrace(AbandonedTrace trace) Adds an object to the list of objects being traced.protected voidClears the list of objects being traced by this object.voidclose()Subclasses can implement this nop.protected voidCloses this resource and if an exception is caught, then callsexceptionHandler.longDeprecated.protected List<AbandonedTrace> getTrace()Gets a list of objects being traced by this object.private voidinit(AbandonedTrace parent) Initializes abandoned tracing for this object.protected voidremoveThisTrace(Object source) Removes this object the source object is tracing.protected voidremoveTrace(AbandonedTrace trace) Removes a child object this object is tracing.protected voidSets the time this object was last used to the current time in milliseconds.protected voidsetLastUsed(long lastUsedMillis) Deprecated.protected voidsetLastUsed(Instant lastUsedInstant) Sets the instant this object was last used.
-
Field Details
-
traceList
A list of objects created by children of this object. -
lastUsedInstant
Last time this connection was used.
-
-
Constructor Details
-
AbandonedTrace
public AbandonedTrace()Creates a new AbandonedTrace without config and without doing abandoned tracing. -
AbandonedTrace
Constructs a new AbandonedTrace with a parent object.- Parameters:
parent- AbandonedTrace parent object.
-
-
Method Details
-
add
-
addTrace
Adds an object to the list of objects being traced.- Parameters:
trace- AbandonedTrace object to add.
-
clearTrace
protected void clearTrace()Clears the list of objects being traced by this object. -
close
Subclasses can implement this nop.- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException- Ignored here, for subclasses.- Since:
- 2.10.0
-
close
Closes this resource and if an exception is caught, then callsexceptionHandler.- Parameters:
exceptionHandler- Consumes exception thrown closing this resource.- Since:
- 2.10.0
-
getLastUsed
Deprecated.Gets the last time this object was used in milliseconds.- Specified by:
getLastUsedin interfaceorg.apache.commons.pool2.TrackedUse- Returns:
- long time in milliseconds.
-
getLastUsedInstant
- Specified by:
getLastUsedInstantin interfaceorg.apache.commons.pool2.TrackedUse
-
getTrace
Gets a list of objects being traced by this object.- Returns:
- List of objects.
-
init
Initializes abandoned tracing for this object.- Parameters:
parent- AbandonedTrace parent object.
-
removeThisTrace
Removes this object the source object is tracing.- Parameters:
source- The object tracing- Since:
- 2.7.0
-
removeTrace
Removes a child object this object is tracing.- Parameters:
trace- AbandonedTrace object to remove.
-
setLastUsed
protected void setLastUsed()Sets the time this object was last used to the current time in milliseconds. -
setLastUsed
Sets the instant this object was last used.- Parameters:
lastUsedInstant- instant.- Since:
- 2.10.0
-
setLastUsed
Deprecated.Sets the time in milliseconds this object was last used.- Parameters:
lastUsedMillis- time in milliseconds.
-
setLastUsed(Instant)