Package com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate

Examples of com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple


        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
    }

    public void testTwoPhaseCommitSync() throws Exception
    {
        final TransactionImple tm = new TransactionImple(0);
        final TestSynchronization sync = new TestSynchronization();
        tm.registerSynchronization(sync);
        assertEquals(TwoPhaseOutcome.PREPARE_READONLY, tm.doPrepare());
        tm.doCommit();
        assertTrue(sync.isBeforeCompletionDone());
        assertTrue(sync.isAfterCompletionDone());
        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
    }
View Full Code Here


    }

    public void testTwoPhaseCommitSyncViaXATerminator() throws Exception
    {
        final Xid xid = new XidImple(new Uid());
        final TransactionImple tm = TxImporter.importTransaction(xid);
        final TestSynchronization sync = new TestSynchronization();
        tm.registerSynchronization(sync);
        final XATerminator xaTerminator = new XATerminatorImple();
        assertEquals(XAResource.XA_RDONLY, xaTerminator.prepare(xid));
        // note that unlike the above test we don't call commit - the XA_RDONLY means its finished, per XA semantics.
        assertTrue(sync.isBeforeCompletionDone());
        assertTrue(sync.isAfterCompletionDone());
        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
    }
View Full Code Here

        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
    }

    public void testTwoPhaseCommitSyncWithXAOK() throws Exception
    {
        final TransactionImple tm = new TransactionImple(0);
        final TestSynchronization sync = new TestSynchronization();
        tm.registerSynchronization(sync);
        final TestXAResource xaResource = new TestXAResource();
        xaResource.setPrepareReturnValue(XAResource.XA_OK);
        tm.enlistResource(xaResource);
        assertEquals(TwoPhaseOutcome.PREPARE_OK, tm.doPrepare());
        tm.doCommit();
        assertTrue(sync.isBeforeCompletionDone());
        assertTrue(sync.isAfterCompletionDone());
        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
    }
View Full Code Here

    }

    public void testTwoPhaseCommitSyncWithXAOKViaXATerminator() throws Exception
    {
        final Xid xid = new XidImple(new Uid());
        final TransactionImple tm = TxImporter.importTransaction(xid);
        final TestSynchronization sync = new TestSynchronization();
        tm.registerSynchronization(sync);
        final TestXAResource xaResource = new TestXAResource();
        xaResource.setPrepareReturnValue(XAResource.XA_OK);
        tm.enlistResource(xaResource);
        final XATerminator xaTerminator = new XATerminatorImple();
        assertEquals(XAResource.XA_OK, xaTerminator.prepare(xid));
        xaTerminator.commit(xid, false);
        assertTrue(sync.isBeforeCompletionDone());
        assertTrue(sync.isAfterCompletionDone());
        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
    }
View Full Code Here

        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
    }

    public void testTwoPhaseCommitSyncWithRollbackOnly() throws Exception
    {
        final TransactionImple tm = new TransactionImple(0);
        final TestSynchronization sync = new TestSynchronization();
        tm.registerSynchronization(sync);
        tm.setRollbackOnly();
        assertEquals(TwoPhaseOutcome.PREPARE_NOTOK, tm.doPrepare());
        tm.doRollback();
        assertFalse(sync.isBeforeCompletionDone());
        assertTrue(sync.isAfterCompletionDone());
        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
    }
View Full Code Here

    }

    public void testTwoPhaseCommitSyncWithRollbackOnlyViaXATerminator() throws Exception
    {
        final Xid xid = new XidImple(new Uid());
        final TransactionImple tm = TxImporter.importTransaction(xid);
        final TestSynchronization sync = new TestSynchronization();
        tm.registerSynchronization(sync);
        tm.setRollbackOnly();
        final XATerminator xaTerminator = new XATerminatorImple();

        try {
            xaTerminator.prepare(xid);
        } catch(XAException e) {
            assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
            // expected - we tried to prepare a rollbackonly tx.
        }
        // no need to call rollback - the XA_RBROLLBACK code indicates it's been done.
        assertFalse(sync.isBeforeCompletionDone());
        assertTrue(sync.isAfterCompletionDone());
        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
    }
View Full Code Here

   */
  public void commit(Xid xid, boolean onePhase) throws XAException
  {
    try
    {
      TransactionImple tx = TxImporter.getImportedTransaction(xid);

      if (tx == null)
        throw new XAException(XAException.XAER_INVAL);

      if (tx.activated())
      {
        if (onePhase)
          tx.doOnePhaseCommit();
        else
          tx.doCommit();

        TxImporter.removeImportedTransaction(xid);
      }
      else
        throw new XAException(XAException.XA_RETRY);
View Full Code Here

   */
  public void forget(Xid xid) throws XAException
  {
    try
    {
      TransactionImple tx = TxImporter.getImportedTransaction(xid);

      if (tx == null)
        throw new XAException(XAException.XAER_INVAL);

      tx.doForget();
    }
    catch (Exception ex)
    {
      throw new XAException(XAException.XAER_RMERR);
    }
View Full Code Here

   */
  public int prepare(Xid xid) throws XAException
  {
    try
    {
      TransactionImple tx = TxImporter.getImportedTransaction(xid);

      if (tx == null)
        throw new XAException(XAException.XAER_INVAL);

      switch (tx.doPrepare())
      {
      case TwoPhaseOutcome.PREPARE_READONLY:
        TxImporter.removeImportedTransaction(xid);
        return XAResource.XA_RDONLY;
      case TwoPhaseOutcome.PREPARE_NOTOK:
                // the JCA API spec limits what we can do in terms of reporting problems.
                // try to use the exception code and cause to provide info whilst
                // remaining API compliant.  JBTM-427.
                Exception initCause = null;
                int xaExceptionCode = XAException.XA_RBROLLBACK;
                try {
                    tx.doRollback();
                } catch(HeuristicCommitException e) {
                    initCause = e;
                    xaExceptionCode = XAException.XAER_RMERR;
                } catch (HeuristicMixedException e) {
                    initCause = e;
View Full Code Here

            finished = true;
          }

          if (uid.notEquals(Uid.nullUid()))
          {
            TransactionImple tx = TxImporter.recoverTransaction(uid);
            if (tx != null)
              values.push(tx);
          }
          else
            finished = true;

        } while (!finished);

        if (values.size() > 0)
        {
          int index = 0;

          indoubt = new Xid[values.size()];

          while (!values.empty())
          {
            com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple tx = (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple) values.pop();

            indoubt[index] = tx.baseXid();
            index++;
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple

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.