Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.DefaultTransactionStatus


                boolean activeTx = TransactionSynchronizationManager.isActualTransactionActive();
                if (!activeTx) {
                    activeTx = status.isNewTransaction() && !status.isCompleted();
                    if (!activeTx) {
                        if (DefaultTransactionStatus.class.isAssignableFrom(status.getClass())) {
                            DefaultTransactionStatus defStatus = DefaultTransactionStatus.class.cast(status);
                            activeTx = defStatus.hasTransaction() && !status.isCompleted();
                        }
                    }
                }
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Is actual transaction active: " + activeTx);
View Full Code Here


      this.debug = debug;
    }

    @Override
    public void run() {
      DefaultTransactionStatus status = prepareTransactionStatus(
          this.definition, (this.actualTransaction ? this : null),
          this.newTransaction, this.newSynchronization, this.debug, null);
      try {
        this.result = this.callback.doInTransaction(status);
        triggerBeforeCommit(status);
      }
      catch (Throwable ex) {
        this.exception = ex;
        uowManager.setRollbackOnly();
      }
      finally {
        if (status.isLocalRollbackOnly()) {
          if (status.isDebug()) {
            logger.debug("Transactional code has requested rollback");
          }
          uowManager.setRollbackOnly();
        }
        triggerBeforeCompletion(status);
        if (status.isNewSynchronization()) {
          List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
          TransactionSynchronizationManager.clear();
          if (!synchronizations.isEmpty()) {
            uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
          }
View Full Code Here

*/
public class TransactionSupportTests extends TestCase {

  public void testNoExistingTransaction() {
    PlatformTransactionManager tm = new TestTransactionManager(false, true);
    DefaultTransactionStatus status1 = (DefaultTransactionStatus)
        tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
    assertTrue("Must not have transaction", status1.getTransaction() == null);

    DefaultTransactionStatus status2 = (DefaultTransactionStatus)
        tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
    assertTrue("Must have transaction", status2.getTransaction() != null);
    assertTrue("Must be new transaction", status2.isNewTransaction());

    try {
      tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY));
      fail("Should not have thrown NoTransactionException");
    }
View Full Code Here

    }
  }

  public void testExistingTransaction() {
    PlatformTransactionManager tm = new TestTransactionManager(true, true);
    DefaultTransactionStatus status1 = (DefaultTransactionStatus)
        tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
    assertTrue("Must have transaction", status1.getTransaction() != null);
    assertTrue("Must not be new transaction", !status1.isNewTransaction());

    DefaultTransactionStatus status2 = (DefaultTransactionStatus)
        tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
    assertTrue("Must have transaction", status2.getTransaction() != null);
    assertTrue("Must not be new transaction", !status2.isNewTransaction());

    try {
      DefaultTransactionStatus status3 = (DefaultTransactionStatus)
          tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY));
      assertTrue("Must have transaction", status3.getTransaction() != null);
      assertTrue("Must not be new transaction", !status3.isNewTransaction());
    }
    catch (NoTransactionException ex) {
      fail("Should not have thrown NoTransactionException");
    }
  }
View Full Code Here

      this.newSynchronization = newSynchronization;
      this.debug = debug;
    }

    public void run() {
      DefaultTransactionStatus status = prepareTransactionStatus(
          this.definition, (this.actualTransaction ? this : null),
          this.newTransaction, this.newSynchronization, this.debug, null);
      try {
        this.result = this.callback.doInTransaction(status);
        triggerBeforeCommit(status);
      }
      catch (Throwable ex) {
        this.exception = ex;
        uowManager.setRollbackOnly();
      }
      finally {
        if (status.isLocalRollbackOnly()) {
          if (status.isDebug()) {
            logger.debug("Transactional code has requested rollback");
          }
          uowManager.setRollbackOnly();
        }
        triggerBeforeCompletion(status);
        if (status.isNewSynchronization()) {
          List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
          TransactionSynchronizationManager.clear();
          uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
        }
      }
View Full Code Here

                    activeTx = TransactionSynchronizationManager.isActualTransactionActive();
                    if (!activeTx) {
                        activeTx = status.isNewTransaction() && !status.isCompleted();
                        if (!activeTx) {
                            if (DefaultTransactionStatus.class.isAssignableFrom(status.getClass())) {
                                DefaultTransactionStatus defStatus = DefaultTransactionStatus.class.cast(status);
                                activeTx = defStatus.hasTransaction() && !status.isCompleted();
                            }
                        }
                    }
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Is actual transaction active: " + activeTx);
View Full Code Here

                    activeTx = TransactionSynchronizationManager.isActualTransactionActive();
                    if (!activeTx) {
                        activeTx = status.isNewTransaction() && !status.isCompleted();
                        if (!activeTx) {
                            if (DefaultTransactionStatus.class.isAssignableFrom(status.getClass())) {
                                DefaultTransactionStatus defStatus = DefaultTransactionStatus.class
                                    .cast(status);
                                activeTx = defStatus.hasTransaction() && !status.isCompleted();
                            }
                        }
                    }
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Is actual transaction active: " + activeTx);
View Full Code Here

      this.newSynchronization = newSynchronization;
      this.debug = debug;
    }

    public void run() {
      DefaultTransactionStatus status = prepareTransactionStatus(
          this.definition, (this.actualTransaction ? this : null),
          this.newTransaction, this.newSynchronization, this.debug, null);
      try {
        this.result = this.callback.doInTransaction(status);
        triggerBeforeCommit(status);
      }
      catch (Throwable ex) {
        this.exception = ex;
        uowManager.setRollbackOnly();
      }
      finally {
        if (status.isLocalRollbackOnly()) {
          if (status.isDebug()) {
            logger.debug("Transactional code has requested rollback");
          }
          uowManager.setRollbackOnly();
        }
        triggerBeforeCompletion(status);
        if (status.isNewSynchronization()) {
          List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
          TransactionSynchronizationManager.clear();
          if (!synchronizations.isEmpty()) {
            uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
          }
View Full Code Here

      TransactionDefinition transactionDefinition)
          throws TransactionException {
    @SuppressWarnings("unchecked")
    List<DefaultTransactionStatus> list = (List<DefaultTransactionStatus>) transactionObject;
    for (PlatformTransactionManager transactionManager : transactionManagers) {
      DefaultTransactionStatus element = (DefaultTransactionStatus) transactionManager
          .getTransaction(transactionDefinition);
      list.add(element);
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.transaction.support.DefaultTransactionStatus

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.