java.lang.Object
com.aoapps.sql.wrapper.ConnectionWrapperImpl
com.aoapps.sql.tracker.ConnectionTrackerImpl
- All Implemented Interfaces:
ConnectionTracker,OnCloseHandler,TrackedArrays,TrackedBlobs,TrackedCallableStatements,TrackedClobs,TrackedDatabaseMetaDatas,TrackedInputStreams,TrackedNClobs,TrackedOutputStreams,TrackedParameterMetaDatas,TrackedPreparedStatements,TrackedReaders,TrackedRefs,TrackedResultSetMetaDatas,TrackedResultSets,TrackedRowIds,TrackedSavepoints,TrackedSQLDatas,TrackedSQLInputs,TrackedSQLOutputs,TrackedSQLXMLs,TrackedStatements,TrackedStructs,TrackedWriters,ConnectionWrapper,Wrapper,AutoCloseable,Connection,Wrapper
Tracks a
Connection for unclosed or unfreed objects.- Author:
- AO Industries, Inc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LevelThe logging level that enables allocation stack trace logging.Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Constructor Summary
ConstructorsConstructorDescriptionConnectionTrackerImpl(DriverTracker driver, Connection wrapped) Creates a newConnectiontracker.ConnectionTrackerImpl(Connection wrapped) Creates a newConnectiontracker. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalls onClose handlers, clears all tracking, then callsdoAbort(java.util.concurrent.Executor).voidaddOnClose(Runnable onCloseHandler) Will call the handler once on close/free.protected voidClears all tracking.voidclose()Calls onClose handlers, closes all tracked objects, rolls-back any transaction in-progress and puts back in auto-commit mode, then callsdoClose().protected ThrowablecloseTracked(Throwable t0, String sourceMethod) Closes / frees all tracked objects except savepoints, which are expected to be closed by a followingrollback().voidcommit()Removes tracking of savepoints while committing the transaction.protected voidPerforms the actual abort, called once all onClose handlers completed and all tracking cleared.protected voiddoClose()Performs the actual close, called once all onClose handlers completed and all tracked objects closed.final Map<Array, ArrayTrackerImpl> Gets all the arrays that have not yet been freed.final Map<Blob, BlobTrackerImpl> Gets all the blobs that have not yet been freed.Gets all the callable statements that have not yet been closed.final Map<Clob, ClobTrackerImpl> Gets all the clobs that have not yet been freed.Gets all the meta data that have not yet been closed.final Map<InputStream, InputStreamTracker> Gets all the input streams that have not yet been closed.final Map<NClob, NClobTrackerImpl> Gets all the nclobs that have not yet been freed.final Map<OutputStream, OutputStreamTracker> Gets all the output streams that have not yet been closed.Gets all the meta data that have not yet been closed.Gets all the prepared statements that have not yet been closed.final Map<Reader, ReaderTracker> Gets all the readers that have not yet been closed.final Map<Ref, RefTrackerImpl> Gets all the refs that have not yet been closed.Gets all the meta data that have not yet been closed.final Map<ResultSet, ResultSetTrackerImpl> Gets all the result sets that have not yet been closed.final Map<RowId, RowIdTrackerImpl> Gets all the row IDs that have not yet been closed.final Map<Savepoint, SavepointTrackerImpl> Gets all the savepoints that have not yet been released.final Map<SQLData, SQLDataTrackerImpl> Gets all the SQL datas that have not yet been closed.final Map<SQLInput, SQLInputTrackerImpl> Gets all the SQL inputs that have not yet been closed.final Map<SQLOutput, SQLOutputTrackerImpl> Gets all the SQL outputs that have not yet been closed.final Map<SQLXML, SQLXMLTrackerImpl> Gets all the SQL XMLs that have not yet been freed.final Map<Statement, StatementTrackerImpl> Gets all the statements that have not yet been closed.final Map<Struct, StructTrackerImpl> Gets all the structs that have not yet been closed.final Map<Writer, WriterTracker> Gets all the writers that have not yet been closed.protected ArrayTrackerImplnewArrayWrapper(StatementWrapperImpl stmtWrapper, Array array) protected BlobTrackerImplnewBlobWrapper(Blob blob) protected CallableStatementTrackerImplprotected ClobTrackerImplnewClobWrapper(Clob clob) protected DatabaseMetaDataTrackerImplnewDatabaseMetaDataWrapper(DatabaseMetaData metaData) protected InputStreamTrackerprotected NClobTrackerImplnewNClobWrapper(NClob nclob) protected OutputStreamTrackerprotected ParameterMetaDataTrackerImplnewParameterMetaDataWrapper(ParameterMetaData metaData) protected PreparedStatementTrackerImplprotected ReaderTrackerprotected RefTrackerImplnewRefWrapper(Ref ref) protected ResultSetMetaDataTrackerImplnewResultSetMetaDataWrapper(ResultSetMetaData metaData) protected ResultSetTrackerImplnewResultSetWrapper(StatementWrapperImpl stmtWrapper, ResultSet results) protected RowIdTrackerImplnewRowIdWrapper(RowId rowId) protected SavepointTrackerImplnewSavepointWrapper(Savepoint savepoint) protected SQLDataTrackerImplnewSQLDataWrapper(SQLData sqlData) protected SQLInputTrackerImplnewSQLInputWrapper(SQLInput sqlInput) protected SQLOutputTrackerImplnewSQLOutputWrapper(SQLOutput sqlOutput) protected SQLXMLTrackerImplnewSQLXMLWrapper(SQLXML sqlXml) protected StatementTrackerImplnewStatementWrapper(Statement stmt) protected StructTrackerImplnewStructWrapper(Struct struct) protected WriterTrackernewWriterWrapper(Writer out) protected ThrowableReleases all tracked savepoints.voidreleaseSavepoint(Savepoint savepoint) Removes tracking while releasing the savepoint.voidrollback()Removes tracking of savepoints while rolling-back the transaction.voidRemoves tracking of all savepoints after the given savepoint, the rolls-back to the given savepoint.voidsetAutoCommit(boolean autoCommit) Removes tracking of savepoints when auto-commit mode is enabled (which commits any transaction in-progress).Methods inherited from class com.aoapps.sql.wrapper.ConnectionWrapperImpl
createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, getDriver, getMetaData, getWrapped, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, setSavepoint, setSavepoint, toString, unwrapArray, unwrapBlob, unwrapClob, unwrapInputStream, unwrapNClob, unwrapReader, unwrapRef, unwrapRowId, unwrapSavepoint, unwrapSQLXML, unwrapStruct, wrapArray, wrapBlob, wrapCallableStatement, wrapClob, wrapDatabaseMetaData, wrapInputStream, wrapNClob, wrapOutputStream, wrapParameterMetaData, wrapPreparedStatement, wrapReader, wrapRef, wrapResultSet, wrapResultSetMetaData, wrapRowId, wrapSavepoint, wrapSQLData, wrapSQLInput, wrapSQLOutput, wrapSQLXML, wrapStatement, wrapStruct, wrapWriterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValidMethods inherited from interface com.aoapps.sql.wrapper.ConnectionWrapper
clearWarnings, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, getWrapped, getWrappedConnection, isClosed, isReadOnly, isValid, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setTransactionIsolation, setTypeMapMethods inherited from interface com.aoapps.sql.wrapper.Wrapper
isWrapperFor, unwrap
-
Field Details
-
ALLOCATION_STACKTRACE_LOG_LEVEL
The logging level that enables allocation stack trace logging.
-
-
Constructor Details
-
ConnectionTrackerImpl
Creates a newConnectiontracker. -
ConnectionTrackerImpl
Creates a newConnectiontracker.
-
-
Method Details
-
getAllocationStacktrace
-
getAllocationLogger
-
addOnClose
Description copied from interface:OnCloseHandlerWill call the handler once on close/free.- Specified by:
addOnClosein interfaceOnCloseHandler
-
getTrackedArrays
Description copied from interface:TrackedArraysGets all the arrays that have not yet been freed.- Specified by:
getTrackedArraysin interfaceTrackedArrays- Returns:
- The mapping from wrapped array to tracker without any defensive copy.
- See Also:
-
getTrackedBlobs
Description copied from interface:TrackedBlobsGets all the blobs that have not yet been freed.- Specified by:
getTrackedBlobsin interfaceTrackedBlobs- Returns:
- The mapping from wrapped blob to tracker without any defensive copy.
- See Also:
-
getTrackedCallableStatements
Description copied from interface:TrackedCallableStatementsGets all the callable statements that have not yet been closed.- Specified by:
getTrackedCallableStatementsin interfaceTrackedCallableStatements- Returns:
- The mapping from wrapped callable statement to tracker without any defensive copy.
- See Also:
-
getTrackedClobs
Description copied from interface:TrackedClobsGets all the clobs that have not yet been freed. This only containsClob, please see other method forNClob.- Specified by:
getTrackedClobsin interfaceTrackedClobs- Returns:
- The mapping from wrapped clob to tracker without any defensive copy.
- See Also:
-
getTrackedDatabaseMetaDatas
Description copied from interface:TrackedDatabaseMetaDatasGets all the meta data that have not yet been closed. Meta datas are assumed to be closed with their connection.- Specified by:
getTrackedDatabaseMetaDatasin interfaceTrackedDatabaseMetaDatas- Returns:
- The mapping from wrapped meta data to tracker without any defensive copy.
- See Also:
-
getTrackedInputStreams
Description copied from interface:TrackedInputStreamsGets all the input streams that have not yet been closed.- Specified by:
getTrackedInputStreamsin interfaceTrackedInputStreams- Returns:
- The mapping from wrapped input stream to tracker without any defensive copy.
- See Also:
-
getTrackedNClobs
Description copied from interface:TrackedNClobsGets all the nclobs that have not yet been freed.- Specified by:
getTrackedNClobsin interfaceTrackedNClobs- Returns:
- The mapping from wrapped nclob to tracker without any defensive copy.
- See Also:
-
getTrackedOutputStreams
Description copied from interface:TrackedOutputStreamsGets all the output streams that have not yet been closed.- Specified by:
getTrackedOutputStreamsin interfaceTrackedOutputStreams- Returns:
- The mapping from wrapped output stream to tracker without any defensive copy.
- See Also:
-
getTrackedParameterMetaDatas
Description copied from interface:TrackedParameterMetaDatasGets all the meta data that have not yet been closed. Meta datas are assumed to be closed with their prepared statement.- Specified by:
getTrackedParameterMetaDatasin interfaceTrackedParameterMetaDatas- Returns:
- The mapping from wrapped meta data to tracker without any defensive copy.
- See Also:
-
getTrackedPreparedStatements
Description copied from interface:TrackedPreparedStatementsGets all the prepared statements that have not yet been closed. This only containsPreparedStatement, please see other method forCallableStatement.- Specified by:
getTrackedPreparedStatementsin interfaceTrackedPreparedStatements- Returns:
- The mapping from wrapped prepared statement to tracker without any defensive copy.
- See Also:
-
getTrackedReaders
Description copied from interface:TrackedReadersGets all the readers that have not yet been closed.- Specified by:
getTrackedReadersin interfaceTrackedReaders- Returns:
- The mapping from wrapped reader to tracker without any defensive copy.
- See Also:
-
getTrackedRefs
Description copied from interface:TrackedRefsGets all the refs that have not yet been closed. Refs are assumed to be closed with their connection.- Specified by:
getTrackedRefsin interfaceTrackedRefs- Returns:
- The mapping from wrapped ref to tracker without any defensive copy.
- See Also:
-
getTrackedResultSets
Description copied from interface:TrackedResultSetsGets all the result sets that have not yet been closed.- Specified by:
getTrackedResultSetsin interfaceTrackedResultSets- Returns:
- The mapping from wrapped result set to tracker without any defensive copy.
- See Also:
-
getTrackedResultSetMetaDatas
Description copied from interface:TrackedResultSetMetaDatasGets all the meta data that have not yet been closed. Meta datas are assumed to be closed with their result set.- Specified by:
getTrackedResultSetMetaDatasin interfaceTrackedResultSetMetaDatas- Returns:
- The mapping from wrapped meta data to tracker without any defensive copy.
- See Also:
-
getTrackedRowIds
Description copied from interface:TrackedRowIdsGets all the row IDs that have not yet been closed. Row IDs are assumed to be closed with their connection.- Specified by:
getTrackedRowIdsin interfaceTrackedRowIds- Returns:
- The mapping from wrapped row ID to tracker without any defensive copy.
- See Also:
-
getTrackedSQLDatas
Description copied from interface:TrackedSQLDatasGets all the SQL datas that have not yet been closed.- Specified by:
getTrackedSQLDatasin interfaceTrackedSQLDatas- Returns:
- The mapping from wrapped SQL data to tracker without any defensive copy.
- See Also:
-
getTrackedSQLInputs
Description copied from interface:TrackedSQLInputsGets all the SQL inputs that have not yet been closed.- Specified by:
getTrackedSQLInputsin interfaceTrackedSQLInputs- Returns:
- The mapping from wrapped SQL input to tracker without any defensive copy.
- See Also:
-
getTrackedSQLOutputs
Description copied from interface:TrackedSQLOutputsGets all the SQL outputs that have not yet been closed.- Specified by:
getTrackedSQLOutputsin interfaceTrackedSQLOutputs- Returns:
- The mapping from wrapped SQL output to tracker without any defensive copy.
- See Also:
-
getTrackedSQLXMLs
Description copied from interface:TrackedSQLXMLsGets all the SQL XMLs that have not yet been freed.- Specified by:
getTrackedSQLXMLsin interfaceTrackedSQLXMLs- Returns:
- The mapping from wrapped SQL XML to tracker without any defensive copy.
- See Also:
-
getTrackedSavepoints
Description copied from interface:TrackedSavepointsGets all the savepoints that have not yet been released.- Specified by:
getTrackedSavepointsin interfaceTrackedSavepoints- Returns:
- The mapping from wrapped savepoint to tracker without any defensive copy.
- See Also:
-
getTrackedStatements
Description copied from interface:TrackedStatementsGets all the statements that have not yet been closed. This only containsStatement, please see other methods forPreparedStatementandCallableStatement.- Specified by:
getTrackedStatementsin interfaceTrackedStatements- Returns:
- The mapping from wrapped statement to tracker without any defensive copy.
- See Also:
-
getTrackedStructs
Description copied from interface:TrackedStructsGets all the structs that have not yet been closed. Structs are assumed to be closed with their connection.- Specified by:
getTrackedStructsin interfaceTrackedStructs- Returns:
- The mapping from wrapped struct to tracker without any defensive copy.
- See Also:
-
getTrackedWriters
Description copied from interface:TrackedWritersGets all the writers that have not yet been closed.- Specified by:
getTrackedWritersin interfaceTrackedWriters- Returns:
- The mapping from wrapped writer to tracker without any defensive copy.
- See Also:
-
closeTracked
Closes / frees all tracked objects except savepoints, which are expected to be closed by a followingrollback(). -
clearTracking
protected void clearTracking()Clears all tracking. -
releaseAllTrackedSavepoints
Releases all tracked savepoints. -
newArrayWrapper
- Overrides:
newArrayWrapperin classConnectionWrapperImpl
-
newBlobWrapper
- Overrides:
newBlobWrapperin classConnectionWrapperImpl
-
newCallableStatementWrapper
- Overrides:
newCallableStatementWrapperin classConnectionWrapperImpl
-
newClobWrapper
- Overrides:
newClobWrapperin classConnectionWrapperImpl
-
newDatabaseMetaDataWrapper
- Overrides:
newDatabaseMetaDataWrapperin classConnectionWrapperImpl
-
newInputStreamWrapper
- Overrides:
newInputStreamWrapperin classConnectionWrapperImpl
-
newNClobWrapper
- Overrides:
newNClobWrapperin classConnectionWrapperImpl
-
newOutputStreamWrapper
- Overrides:
newOutputStreamWrapperin classConnectionWrapperImpl
-
newParameterMetaDataWrapper
- Overrides:
newParameterMetaDataWrapperin classConnectionWrapperImpl
-
newPreparedStatementWrapper
- Overrides:
newPreparedStatementWrapperin classConnectionWrapperImpl
-
newReaderWrapper
- Overrides:
newReaderWrapperin classConnectionWrapperImpl
-
newRefWrapper
- Overrides:
newRefWrapperin classConnectionWrapperImpl
-
newResultSetWrapper
protected ResultSetTrackerImpl newResultSetWrapper(StatementWrapperImpl stmtWrapper, ResultSet results) - Overrides:
newResultSetWrapperin classConnectionWrapperImpl
-
newResultSetMetaDataWrapper
- Overrides:
newResultSetMetaDataWrapperin classConnectionWrapperImpl
-
newRowIdWrapper
- Overrides:
newRowIdWrapperin classConnectionWrapperImpl
-
newSQLDataWrapper
- Overrides:
newSQLDataWrapperin classConnectionWrapperImpl
-
newSQLInputWrapper
- Overrides:
newSQLInputWrapperin classConnectionWrapperImpl
-
newSQLOutputWrapper
- Overrides:
newSQLOutputWrapperin classConnectionWrapperImpl
-
newSQLXMLWrapper
- Overrides:
newSQLXMLWrapperin classConnectionWrapperImpl
-
newSavepointWrapper
- Overrides:
newSavepointWrapperin classConnectionWrapperImpl
-
newStatementWrapper
- Overrides:
newStatementWrapperin classConnectionWrapperImpl
-
newStructWrapper
- Overrides:
newStructWrapperin classConnectionWrapperImpl
-
newWriterWrapper
- Overrides:
newWriterWrapperin classConnectionWrapperImpl
-
setAutoCommit
Removes tracking of savepoints when auto-commit mode is enabled (which commits any transaction in-progress).- Specified by:
setAutoCommitin interfaceConnection- Specified by:
setAutoCommitin interfaceConnectionTracker- Specified by:
setAutoCommitin interfaceConnectionWrapper- Throws:
SQLException- See Also:
-
commit
Removes tracking of savepoints while committing the transaction.- Specified by:
commitin interfaceConnection- Specified by:
commitin interfaceConnectionTracker- Specified by:
commitin interfaceConnectionWrapper- Throws:
SQLException- See Also:
-
rollback
Removes tracking of savepoints while rolling-back the transaction.- Specified by:
rollbackin interfaceConnection- Specified by:
rollbackin interfaceConnectionTracker- Specified by:
rollbackin interfaceConnectionWrapper- Throws:
SQLException- See Also:
-
close
Calls onClose handlers, closes all tracked objects, rolls-back any transaction in-progress and puts back in auto-commit mode, then callsdoClose().This default implementation calls
doClose().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Specified by:
closein interfaceConnectionTracker- Specified by:
closein interfaceConnectionWrapper- Overrides:
closein classConnectionWrapperImpl- Throws:
SQLException- See Also:
-
rollback
Removes tracking of all savepoints after the given savepoint, the rolls-back to the given savepoint.- Specified by:
rollbackin interfaceConnection- Specified by:
rollbackin interfaceConnectionTracker- Specified by:
rollbackin interfaceConnectionWrapper- Overrides:
rollbackin classConnectionWrapperImpl- Throws:
SQLException- See Also:
-
releaseSavepoint
Removes tracking while releasing the savepoint.- Specified by:
releaseSavepointin interfaceConnection- Specified by:
releaseSavepointin interfaceConnectionTracker- Specified by:
releaseSavepointin interfaceConnectionWrapper- Overrides:
releaseSavepointin classConnectionWrapperImpl- Throws:
SQLException- See Also:
-
abort
Calls onClose handlers, clears all tracking, then callsdoAbort(java.util.concurrent.Executor). Trusts the underlying implementation ofConnection.abort(java.util.concurrent.Executor)will free all resources.This default implementation calls
doAbort(java.util.concurrent.Executor).- Specified by:
abortin interfaceConnection- Specified by:
abortin interfaceConnectionTracker- Specified by:
abortin interfaceConnectionWrapper- Overrides:
abortin classConnectionWrapperImpl- Throws:
SQLException- See Also:
-
doClose
Performs the actual close, called once all onClose handlers completed and all tracked objects closed.This default implementation calls
super.close()- Throws:
SQLException- See Also:
-
doAbort
Performs the actual abort, called once all onClose handlers completed and all tracking cleared.This default implementation calls
super.abort(executor)- Throws:
SQLException- See Also:
-
