/** * Wrap the given <code>Connection</code> in a Proxy such that attributes * that might be set will be restored before the connection is closed * (and potentially restored to a pool). */ protected Connection getAttributeRestoringConnection(Connection conn) { return (Connection)Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] { Connection.class }, new AttributeRestoringConnectionInvocationHandler(conn)); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("setAutoCommit")) { setAutoCommit(((Boolean)args[0]).booleanValue()); } else if (method.getName().equals("setTransactionIsolation")) { setTransactionIsolation(((Integer)args[0]).intValue()); } else if (method.getName().equals("close")) { close(); } else { try { return method.invoke(conn, args); } catch(InvocationTargetException ite) { throw (ite.getCause() != null ? ite.getCause() : ite); } } return null; }
/** * Attempts to restore the auto commit and transaction isolation connection * attributes of the wrapped connection to their original values (if they * were overwritten). */ public void restoreOriginalAtributes() { try { if (overwroteOriginalAutoCommitValue) { conn.setAutoCommit(originalAutoCommitValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original auto commit setting.", t); } try { if (overwroteOriginalTxIsolationValue) { conn.setTransactionIsolation(originalTxIsolationValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original transaction isolation setting.", t); } }
(AttributeRestoringConnectionInvocationHandler)invocationHandler; connHandler.restoreOriginalAtributes(); closeConnection(connHandler.getWrappedConnection()); return;
/** * 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. */ public void close() throws SQLException { restoreOriginalAtributes(); conn.close(); } }
(AttributeRestoringConnectionInvocationHandler)invocationHandler; connHandler.restoreOriginalAtributes(); closeConnection(connHandler.getWrappedConnection()); return;
/** * 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. */ public void close() throws SQLException { restoreOriginalAtributes(); conn.close(); } }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("setAutoCommit")) { setAutoCommit(((Boolean)args[0]).booleanValue()); } else if (method.getName().equals("setTransactionIsolation")) { setTransactionIsolation(((Integer)args[0]).intValue()); } else if (method.getName().equals("close")) { close(); } else { try { return method.invoke(conn, args); } catch(InvocationTargetException ite) { throw (ite.getCause() != null ? ite.getCause() : ite); } } return null; }
(AttributeRestoringConnectionInvocationHandler)invocationHandler; connHandler.restoreOriginalAtributes(); closeConnection(connHandler.getWrappedConnection()); return;
/** * 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. */ public void close() throws SQLException { restoreOriginalAtributes(); conn.close(); } }
/** * Wrap the given <code>Connection</code> in a Proxy such that attributes * that might be set will be restored before the connection is closed * (and potentially restored to a pool). */ protected Connection getAttributeRestoringConnection(Connection conn) { return (Connection)Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] { Connection.class }, new AttributeRestoringConnectionInvocationHandler(conn)); }
/** * Attempts to restore the auto commit and transaction isolation connection * attributes of the wrapped connection to their original values (if they * were overwritten). */ public void restoreOriginalAtributes() { try { if (overwroteOriginalAutoCommitValue) { conn.setAutoCommit(originalAutoCommitValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original auto commit setting.", t); } try { if (overwroteOriginalTxIsolationValue) { conn.setTransactionIsolation(originalTxIsolationValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original transaction isolation setting.", t); } }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("setAutoCommit")) { setAutoCommit(((Boolean)args[0]).booleanValue()); } else if (method.getName().equals("setTransactionIsolation")) { setTransactionIsolation(((Integer)args[0]).intValue()); } else if (method.getName().equals("close")) { close(); } else { return method.invoke(conn, args); } return null; }
(AttributeRestoringConnectionInvocationHandler)invocationHandler; connHandler.restoreOriginalAtributes(); closeConnection(connHandler.getWrappedConnection()); return;
/** * 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. */ public void close() throws SQLException { restoreOriginalAtributes(); conn.close(); } }
/** * Wrap the given <code>Connection</code> in a Proxy such that attributes * that might be set will be restored before the connection is closed * (and potentially restored to a pool). */ protected Connection getAttributeRestoringConnection(Connection conn) { return (Connection)Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] { Connection.class }, new AttributeRestoringConnectionInvocationHandler(conn)); }
/** * Attempts to restore the auto commit and transaction isolation connection * attributes of the wrapped connection to their original values (if they * were overwritten). */ public void restoreOriginalAtributes() { try { if (overwroteOriginalAutoCommitValue) { conn.setAutoCommit(originalAutoCommitValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original auto commit setting.", t); } try { if (overwroteOriginalTxIsolationValue) { conn.setTransactionIsolation(originalTxIsolationValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original transaction isolation setting.", t); } }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("setAutoCommit")) { setAutoCommit(((Boolean)args[0]).booleanValue()); } else if (method.getName().equals("setTransactionIsolation")) { setTransactionIsolation(((Integer)args[0]).intValue()); } else if (method.getName().equals("close")) { close(); } else { return method.invoke(conn, args); } return null; }
/** * Wrap the given <code>Connection</code> in a Proxy such that attributes * that might be set will be restored before the connection is closed * (and potentially restored to a pool). */ protected Connection getAttributeRestoringConnection(Connection conn) { return (Connection)Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] { Connection.class }, new AttributeRestoringConnectionInvocationHandler(conn)); }
/** * Attempts to restore the auto commit and transaction isolation connection * attributes of the wrapped connection to their original values (if they * were overwritten). */ public void restoreOriginalAtributes() { try { if (overwroteOriginalAutoCommitValue) { conn.setAutoCommit(originalAutoCommitValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original auto commit setting.", t); } try { if (overwroteOriginalTxIsolationValue) { conn.setTransactionIsolation(originalTxIsolationValue); } } catch (Throwable t) { getLog().warn("Failed restore connection's original transaction isolation setting.", t); } }