public Object execute(Environment environment) { // reload the execution DbSession dbSession = environment.get(DbSession.class); if (dbSession==null) { throw new PvmException("no "+DbSession.class.getName()+" available in the environment for reloading the execution"); } execution = dbSession.get(ExecutionImpl.class, execution.getDbid()); exceptionHandler.executeHandler(execution, exception); return null; }
public void handle(ExecutionImpl execution, Exception exception) { if (isTransactional) { Environment environment = Environment.getCurrent(); Transaction transaction = (environment!=null ? environment.get(Transaction.class) : null); if (transaction!=null) { log.trace("registering exception handler to "+transaction); CommandService commandService = environment.get(CommandService.class); if (commandService==null) { throw new PvmException("environment doesn't have a command service for registering transactional exception handler", exception); } ExceptionHandlerSynchronization exceptionHandlerSynchronization = new ExceptionHandlerSynchronization( this, execution, exception, commandService ); // registration of the synchronization is delegated to the AfterTxCompletionListener // to avoid a dependency on class Synchronization exceptionHandlerSynchronization.register(transaction); log.trace("registering exception handler to "+transaction); throw new PvmException("transaction exception handler registered handler after transaction completed. make sure this transaction is rolled back", exception); } else { throw new PvmException("no transaction present in the environment for transactional exception handler", exception); } } else { executeHandler(execution, exception); } }