Package org.springframework.transaction

Examples of org.springframework.transaction.TransactionStatus


   */
  private static void executeLogicInNewTransaction(ActivityElement activityXml, ActivityInst activityInst, IAction action) {
    PlatformTransactionManager txManager = ApplicationContextHolder.getBean(PlatformTransactionManager.class);
    DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
    definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    TransactionStatus status = txManager.getTransaction(definition);
    try {
      action.execute(activityXml, activityInst);
      txManager.commit(status);
    } catch (Exception e) {
      txManager.rollback(status);
View Full Code Here


  private static void executeLogicInNewTransaction(ProcessDefine processDefine,
      ProcessInstance processInstance, IAction action) {
    PlatformTransactionManager txManager = ApplicationContextHolder.getBean(PlatformTransactionManager.class);
    DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
    definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    TransactionStatus status = txManager.getTransaction(definition);
    try {
      action.execute(processDefine, processInstance);
      txManager.commit(status);
    } catch (Exception e) {
      txManager.rollback(status);
View Full Code Here

  @Override
  public TransactionStatus begin() {
    if(transactionManager != null) {
      DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
      TransactionStatus txStatus = transactionManager.getTransaction(definition);
      return txStatus;
    } else {
      return null;
    }
  }
View Full Code Here

  @Override
  public TransactionStatus begin(int propagationBehavior) {
    if(transactionManager != null) {
      DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
      definition.setPropagationBehavior(propagationBehavior);
      TransactionStatus txStatus = transactionManager.getTransaction(definition);
      return txStatus;
    } else {
      return null;
    }
  }
View Full Code Here

    this.transactedPolicy = transactedPolicy;
  }

  public <T> T execute(TransactionCallback<T> action)
      throws TransactionException {
    TransactionStatus status = transactedPolicy.begin();
    T result = null;
    try {
      result = action.doInTransaction(status);
    } catch (RuntimeException ex) {
      transactedPolicy.rollbackOnException(status, ex);
View Full Code Here

    return result;
  }
 
  public <T> T execute(int propagationBehavior, TransactionCallback<T> action)
      throws TransactionException {
    TransactionStatus status = transactedPolicy.begin(propagationBehavior);
    T result = null;
    try {
      result = action.doInTransaction(status);
    } catch (RuntimeException ex) {
      transactedPolicy.rollbackOnException(status, ex);
View Full Code Here

  public void registerTransactionManager(TransactionDefinition definition, PlatformTransactionManager transactionManager) {
    getTransactionStatuses().put(transactionManager, transactionManager.getTransaction(definition));
  }

  public void commit(PlatformTransactionManager transactionManager) {
    TransactionStatus transactionStatus = getTransactionStatus(transactionManager);
    transactionManager.commit(transactionStatus);
  }
View Full Code Here

   
    public void testSaveWithCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Id null before adding:
        assertNull(emp.getId());
        // Save:
        this.template.save(emp);
        // Id not null after adding:
View Full Code Here

   
    public void testDoubleCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save:
        this.template.save(emp);
        // Commit the transaction status:
        this.transactionManager.commit(status);
        // The double commit fails:
View Full Code Here

   
    public void testSaveWithTimeout() throws InterruptedException {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp);
        // Go to sleep, waiting for timeout:
        Thread.sleep(2000);
        // Trying to commit will failbecause the transaction has been aborted due to the timeout:
View Full Code Here

TOP

Related Classes of org.springframework.transaction.TransactionStatus

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.