/** * Executes a closure and if it does not throw any exceptions, then it commits the transaction. * If the closure throws an Exception, then the transaction is rolled back. * * @param <T> * @param closure - the work to get exectued. * @throws T if the closure throws it * @throws IOException If the commit fails. */ public <T extends Throwable> void execute(Closure<T> closure) throws T, IOException { boolean success = false; try { closure.execute(this); success = true; } finally { if (success) { commit(); } else { rollback(); } } }
/** * Executes a closure and if it does not throw any exceptions, then it commits the transaction. * If the closure throws an Exception, then the transaction is rolled back. * * @param <T> * @param closure - the work to get exectued. * @throws T if the closure throws it * @throws IOException If the commit fails. */ public <T extends Throwable> void execute(Closure<T> closure) throws T, IOException { boolean success = false; try { closure.execute(this); success = true; } finally { if (success) { commit(); } else { rollback(); } } }
/** * Executes a closure and if it does not throw any exceptions, then it commits the transaction. * If the closure throws an Exception, then the transaction is rolled back. * * @param <T> * @param closure - the work to get exectued. * @throws T if the closure throws it * @throws IOException If the commit fails. */ public <T extends Throwable> void execute(Closure<T> closure) throws T, IOException { boolean success = false; try { closure.execute(this); success = true; } finally { if (success) { commit(); } else { rollback(); } } }
/** * Executes a closure and if it does not throw any exceptions, then it commits the transaction. * If the closure throws an Exception, then the transaction is rolled back. * * @param <T> * @param closure - the work to get exectued. * @throws T if the closure throws it * @throws IOException If the commit fails. */ public <T extends Throwable> void execute(Closure<T> closure) throws T, IOException { boolean success = false; try { closure.execute(this); success = true; } finally { if (success) { commit(); } else { rollback(); } } }