Package org.springframework.transaction.jta

Examples of org.springframework.transaction.jta.JtaTransactionManager


    ut.commit();
    utControl.setThrowable(new HeuristicRollbackException("heuristic exception"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
View Full Code Here


    ut.commit();
    utControl.setThrowable(new SystemException("system exception"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
View Full Code Here

    ut.rollback();
    utControl.setThrowable(new SystemException("system exception"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            public void afterCompletion(int status) {
View Full Code Here

    ut.setRollbackOnly();
    utControl.setThrowable(new IllegalStateException("no existing transaction"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          status.setRollbackOnly();
        }
View Full Code Here

    ut.setRollbackOnly();
    utControl.setThrowable(new SystemException("system exception"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          status.setRollbackOnly();
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
View Full Code Here

    utControl.setVoidCallable(1);
    ut.commit();
    utControl.setVoidCallable(1);
    utControl.replay();

    JtaTransactionManager ptm = newJtaTransactionManager(ut);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    TransactionStatus status = ptm.getTransaction(new DefaultTransactionDefinition());
    assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
    // first commit
    ptm.commit(status);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    try {
      // second commit attempt
      ptm.commit(status);
      fail("Should have thrown IllegalTransactionStateException");
    }
    catch (IllegalTransactionStateException ex) {
      // expected
    }
View Full Code Here

    utControl.setReturnValue(Status.STATUS_ACTIVE, 1);
    ut.rollback();
    utControl.setVoidCallable(1);
    utControl.replay();

    JtaTransactionManager ptm = newJtaTransactionManager(ut);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    TransactionStatus status = ptm.getTransaction(new DefaultTransactionDefinition());
    assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
    // first rollback
    ptm.rollback(status);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    try {
      // second rollback attempt
      ptm.rollback(status);
      fail("Should have thrown IllegalTransactionStateException");
    }
    catch (IllegalTransactionStateException ex) {
      // expected
    }
View Full Code Here

    utControl.setReturnValue(Status.STATUS_ACTIVE, 1);
    ut.rollback();
    utControl.setVoidCallable(1);
    utControl.replay();

    JtaTransactionManager ptm = newJtaTransactionManager(ut);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    TransactionStatus status = ptm.getTransaction(new DefaultTransactionDefinition());
    assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
    // first: rollback
    ptm.rollback(status);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    try {
      // second: commit attempt
      ptm.commit(status);
      fail("Should have thrown IllegalTransactionStateException");
    }
    catch (IllegalTransactionStateException ex) {
      // expected
    }
View Full Code Here

    utControl.verify();
  }


  protected JtaTransactionManager newJtaTransactionManager(UserTransaction ut) {
    return new JtaTransactionManager(ut);
  }
View Full Code Here

  protected JtaTransactionManager newJtaTransactionManager(UserTransaction ut) {
    return new JtaTransactionManager(ut);
  }

  protected JtaTransactionManager newJtaTransactionManager(TransactionManager tm) {
    return new JtaTransactionManager(tm);
  }
View Full Code Here

TOP

Related Classes of org.springframework.transaction.jta.JtaTransactionManager

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.