Search in sources :

Example 11 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class ThreadObject3a method run.

public void run() {
    CurrentImple current = OTSImpleManager.current();
    try {
        current.begin();
        Util.indent(_threadId, 0);
        System.out.println("begin");
        AtomicWorker3.randomOperation(_threadId, 0);
        AtomicWorker3.randomOperation(_threadId, 0);
        if (_commit)
            current.commit(false);
        else
            current.rollback();
        Util.indent(_threadId, 0);
        if (_commit)
            System.out.println("end");
        else
            System.out.println("abort");
    } catch (Exception e) {
        System.err.println(e);
    }
}
Also used : CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple)

Example 12 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class trangrid_i method width.

public short width() throws SystemException {
    CurrentImple current = OTSImpleManager.current();
    org.omg.CosTransactions.Control control = current.get_control();
    org.omg.CosTransactions.Control ptr = control;
    if (ptr != null) {
        System.out.println("trangrid_i.width - found implicit transactional context.");
        ptr = null;
    } else {
        System.err.println("Error: trangrid_i.width - no implicit transactional context.");
        System.exit(0);
    }
    return m_width;
}
Also used : CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple)

Example 13 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class trangrid_i method height.

public short height() throws SystemException {
    System.out.println("height " + Thread.currentThread());
    CurrentImple current = OTSImpleManager.current();
    org.omg.CosTransactions.Control control = current.get_control();
    org.omg.CosTransactions.Control ptr = control;
    if (ptr != null) {
        System.out.println("trangrid_i.height - found implicit transactional context.");
        ptr = null;
    } else {
        System.err.println("Error: trangrid_i.height - no implicit transactional context.");
        System.exit(0);
    }
    return m_height;
}
Also used : CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple)

Example 14 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class SuspendResume method test.

@Test
public void test() throws Exception {
    ORB myORB = null;
    RootOA myOA = null;
    myORB = ORB.getInstance("test");
    myOA = OA.getRootOA(myORB);
    myORB.initORB(new String[] {}, null);
    myOA.initOA();
    ORBManager.setORB(myORB);
    ORBManager.setPOA(myOA);
    CurrentImple current = OTSImpleManager.current();
    Control myControl = null;
    System.out.println("Beginning transaction.");
    try {
        current.begin();
        myControl = current.get_control();
        assertNotNull(myControl);
    } catch (Exception sysEx) {
        sysEx.printStackTrace(System.err);
        fail();
    }
    System.out.println("Committing transaction.");
    try {
        current.commit(true);
        current.resume(myControl);
    } catch (Exception e) {
        fail("commit error: " + e);
        e.printStackTrace(System.err);
    }
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Test completed successfully.");
}
Also used : Control(org.omg.CosTransactions.Control) RootOA(com.arjuna.orbportability.RootOA) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 15 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class ExplicitInterClient method main.

public static void main(String[] args) throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    CurrentImple current = OTSImpleManager.current();
    Control theControl = null;
    String objectReference = args[0];
    SetGet SetGetVar = null;
    short h = 0;
    try {
        current.begin();
        current.begin();
        current.begin();
    } catch (Exception e) {
        TestUtility.fail("Caught exception during begin: " + e);
        e.printStackTrace(System.err);
    }
    try {
        Services serv = new Services(myORB);
        SetGetVar = SetGetHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(objectReference)));
    } catch (Exception ex) {
        TestUtility.fail("Failed to bind to setget server: " + ex);
        ex.printStackTrace(System.err);
    }
    try {
        theControl = current.get_control();
        SetGetVar.set((short) 2, theControl);
        // SetGetVar.set((short) 2, theControl);
        theControl = null;
        System.out.println("Set value.");
    } catch (Exception ex1) {
        TestUtility.fail("Unexpected system exception during set: " + ex1);
        ex1.printStackTrace(System.err);
    }
    try {
        System.out.println("committing first nested action");
        current.commit(true);
        // SetGetVar.set((short) 4, current.get_control());
        System.out.println("committing second nested action");
        current.commit(true);
    } catch (Exception sysEx) {
        TestUtility.fail("Caught unexpected exception during commit: " + sysEx);
        sysEx.printStackTrace(System.err);
    }
    try {
        theControl = current.get_control();
        h = SetGetVar.get(theControl);
        theControl = null;
        System.out.println("Got value.");
    } catch (Exception ex2) {
        TestUtility.fail("Unexpected system exception during get: " + ex2);
        ex2.printStackTrace(System.err);
    }
    try {
        current.commit(true);
        System.out.println("committed top-level action");
    } catch (Exception ep) {
        TestUtility.fail("Caught commit exception for top-level action: " + ep);
        ep.printStackTrace(System.err);
    }
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Passed");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) Control(org.omg.CosTransactions.Control) SetGet(com.hp.mwtests.ts.jts.TestModule.SetGet) RootOA(com.arjuna.orbportability.RootOA) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Aggregations

CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)47 Control (org.omg.CosTransactions.Control)14 SystemException (org.omg.CORBA.SystemException)12 ORB (com.arjuna.orbportability.ORB)9 RootOA (com.arjuna.orbportability.RootOA)9 IOException (java.io.IOException)7 Lock (com.arjuna.ats.txoj.Lock)6 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)6 Coordinator (org.omg.CosTransactions.Coordinator)6 Services (com.arjuna.orbportability.Services)5 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)5 ExplicitInterposition (com.arjuna.ats.jts.ExplicitInterposition)4 Test (org.junit.Test)4 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)3 TestException (com.hp.mwtests.ts.jts.exceptions.TestException)3 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)3 NoTransaction (org.omg.CosTransactions.NoTransaction)3 InterpositionFailed (com.arjuna.ArjunaOTS.InterpositionFailed)2 FatalError (com.arjuna.ats.arjuna.exceptions.FatalError)2 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)2