org.quartz.impl.jdbcjobstore
Class AttributeRestoringConnectionInvocationHandler

java.lang.Object
  extended by org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler
All Implemented Interfaces:
InvocationHandler

public class AttributeRestoringConnectionInvocationHandler
extends Object
implements InvocationHandler

Protects a Connection's attributes from being permanently modfied.

Wraps a provided Connection 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).

See Also:
JobStoreSupport.getConnection(), JobStoreCMT.getNonManagedTXConnection()

Constructor Summary
AttributeRestoringConnectionInvocationHandler(Connection conn)
           
 
Method Summary
 void close()
          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.Logger getLog()
           
 Connection getWrappedConnection()
          Gets the underlying connection to which all operations ultimately defer.
 Object invoke(Object proxy, Method method, Object[] args)
           
 void restoreOriginalAtributes()
          Attempts to restore the auto commit and transaction isolation connection attributes of the wrapped connection to their original values (if they were overwritten).
 void setAutoCommit(boolean autoCommit)
          Sets this connection's auto-commit mode to the given state, saving the original mode.
 void setTransactionIsolation(int level)
          Attempts to change the transaction isolation level to the given level, saving the original level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeRestoringConnectionInvocationHandler

public AttributeRestoringConnectionInvocationHandler(Connection conn)
Method Detail

getLog

protected org.slf4j.Logger getLog()

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Sets 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:
SQLException

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws SQLException
Attempts 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:
SQLException

getWrappedConnection

public 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 standard java.sql.Connection interface.

Returns:
The underlying connection to which all operations ultimately defer.

restoreOriginalAtributes

public void restoreOriginalAtributes()
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 SQLException
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.

Throws:
SQLException


Copyright 2001-2015, Terracotta, Inc.