@Override public <T> T execute(final Command<T> command) { final Transaction standardTransaction = EnvTool.getTransaction(); standardTransaction.begin(); try { return next.execute(command); standardTransaction.setRollbackOnly(); throw e; } catch (final RuntimeException e) { standardTransaction.setRollbackOnly(); throw e; } finally { standardTransaction.complete();
private void handleException(final Environment environment, final Job job, final Throwable exception) { final Transaction transaction = environment.get(Transaction.class); final JobExceptionHandler handler = new JobExceptionHandler(job.getId(), exception, this.eventExecutor.getCommandService()); transaction.registerSynchronization(handler); if (exception instanceof RuntimeException) { throw (RuntimeException) exception; } throw new BonitaRuntimeException("Execution of job (" + job + ") failed: " + exception.getMessage(), exception); }