Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.DefaultTransactionStatus


                    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


    public boolean isNewTransaction() {
        return getTransactionStatus().isNewTransaction();
    }

    public boolean isClientTransaction() {
        DefaultTransactionStatus status = getTransactionStatus();
        return status.hasTransaction() && !status.isNewSynchronization();
    }
View Full Code Here

    public boolean isNewTransaction() {
        return getTransactionStatus().isNewTransaction();
    }

    public boolean isClientTransaction() {
        DefaultTransactionStatus status = getTransactionStatus();
        return status.hasTransaction() && !status.isNewSynchronization();
    }
View Full Code Here

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

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

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

    public void run() {
      DefaultTransactionStatus status = newTransactionStatus(
          this.definition, (this.actualTransaction ? this : null),
          this.newTransaction, this.newSynchronization, this.debug, null);
      try {
        this.result = this.callback.doInTransaction(status);
        triggerBeforeCommit(status);
      }
      finally {
        if (status.isLocalRollbackOnly()) {
          if (status.isDebug()) {
            logger.debug("Transactional code has requested rollback");
          }
          uowManager.setRollbackOnly();
        }
        triggerBeforeCompletion(status);
        if (status.isNewSynchronization()) {
          List synchronizations = TransactionSynchronizationManager.getSynchronizations();
          TransactionSynchronizationManager.clear();
          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

                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

                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

                    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

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.