Package org.quartz.impl.jdbcjobstore
Class AttributeRestoringConnectionInvocationHandler
- java.lang.Object
-
- org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
public class AttributeRestoringConnectionInvocationHandler extends java.lang.Object implements java.lang.reflect.InvocationHandlerProtects a
's attributes from being permanently modified.ConnectionWraps a provided
such that its auto commit and transaction isolation attributes can be overwritten, but will automatically restored to their original values when the connection is actually closed (and potentially returned to a pool for reuse).Connection
-
-
Constructor Summary
Constructors Constructor Description AttributeRestoringConnectionInvocationHandler(java.sql.Connection conn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Attempts to restore the auto commit and transaction isolation connection attributes of the wrapped connection to their original values (if they were overwritten), before finally actually closing the wrapped connection.protected org.slf4j.LoggergetLog()java.sql.ConnectiongetWrappedConnection()Gets the underlying connection to which all operations ultimately defer.java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)voidrestoreOriginalAttributes()Attempts to restore the auto commit and transaction isolation connection attributes of the wrapped connection to their original values (if they were overwritten).voidsetAutoCommit(boolean autoCommit)Sets this connection's auto-commit mode to the given state, saving the original mode.voidsetTransactionIsolation(int level)Attempts to change the transaction isolation level to the given level, saving the original level.
-
-
-
Method Detail
-
getLog
protected org.slf4j.Logger getLog()
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable- Specified by:
invokein interfacejava.lang.reflect.InvocationHandler- Throws:
java.lang.Throwable
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLExceptionSets this connection's auto-commit mode to the given state, saving the original mode. The connection's original auto commit mode is restored when the connection is closed.- Throws:
java.sql.SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLExceptionAttempts to change the transaction isolation level to the given level, saving the original level. The connection's original transaction isolation level is restored when the connection is closed.- Throws:
java.sql.SQLException
-
getWrappedConnection
public java.sql.Connection getWrappedConnection()
Gets the underlying connection to which all operations ultimately defer. This is provided in case a user ever needs to punch through the wrapper to access vendor specific methods outside of the standardjava.sql.Connectioninterface.- Returns:
- The underlying connection to which all operations ultimately defer.
-
restoreOriginalAttributes
public void restoreOriginalAttributes()
Attempts to restore the auto commit and transaction isolation connection attributes of the wrapped connection to their original values (if they were overwritten).
-
close
public void close() throws java.sql.SQLExceptionAttempts to restore the auto commit and transaction isolation connection attributes of the wrapped connection to their original values (if they were overwritten), before finally actually closing the wrapped connection.- Throws:
java.sql.SQLException
-
-