Package org.jbpm.tx

Examples of org.jbpm.tx.Transaction


  }
 
  public void handle(ExecutionImpl execution, Exception exception) {
    if (isTransactional) {
      Environment environment = Environment.getCurrent();
      Transaction transaction = (environment!=null ? environment.getTransaction() : null);
      if (transaction!=null) {
        log.finest("registering exception handler to "+transaction);
        AfterTxCompletionListener afterTxCompletionListener = new AfterTxCompletionListener(
                execution,
                exception,
                environment.getEnvironmentFactory()
        );
        transaction.addListener(afterTxCompletionListener, Transaction.EVENT_AFTERCOMPLETION);
        log.finest("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);
      }
View Full Code Here


      this.exception = exception;
      this.environmentFactory = environmentFactory;
    }

    public void event(Object source, String eventName, Object info) {
      Transaction transaction = (Transaction) source;
      if (! transaction.isRolledBack()) {
        log.warning("no rollback after transactional exception handler. did you forget to rollback the transaction ?");
      }
      CommandService commandService = environmentFactory.get(CommandService.class);
      if (commandService==null) {
        throw new PvmException("environment factory doesn't have a command service");
View Full Code Here

  public Transaction getTransaction() {
    // optimisation: search the block context first, only if that fails, use the default search order
    Context blockContext = contexts.get(CONTEXTNAME_BLOCK);
    if (blockContext!=null) {
      Transaction transaction = blockContext.get(Transaction.class);
      if (transaction!=null) {
        return transaction;
      }
    }
    return get(Transaction.class);
View Full Code Here

  /** This transaction will be marked for rollback.  A command will be associated with the
   * Transaction.EVENT_AFTERCOMPLETION (after the job locks of the current transaction are
   * released).  Then the command will update the Job with the exception details in a separate
   * transaction. */
  protected void handleJobExecutionException(Environment environment, Job job, Throwable exception) {
    Transaction transaction = environment.getTransaction();
    transaction.setRollbackOnly();

    CommandService commandService = (CommandService) environment.get(CommandService.class);
    JobExceptionHandler jobExceptionHandler = new JobExceptionHandler(job.getDbid(), exception, commandService);
    transaction.addListener(jobExceptionHandler, Transaction.EVENT_AFTERCOMPLETION);
  }
View Full Code Here

  public Object execute(Command command) {
    Environment environment = Environment.getCurrent();
    if (environment==null) {
      throw new PvmException("no environment for verifying authorization");
    }
    Transaction transaction = environment.getTransaction();
    if (transaction==null) {
      throw new PvmException("no transaction in environment");
    }
    try {
      return next.execute(command);
    } catch (RuntimeException e) {
      transaction.setRollbackOnly();
      throw e;
    }
  }
View Full Code Here

TOP

Related Classes of org.jbpm.tx.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.