Search in sources :

Example 56 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class GridServer method main.

public static void main(String[] args) throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    String gridReference = args[0];
    grid_i myGrid = new grid_i(100, 100);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(gridReference, myORB.orb().object_to_string(myGrid.getReference()));
        System.out.println("Ready");
        myOA.run();
    } catch (Exception e) {
        TestUtility.fail("**GridServer caught exception: " + e);
    }
    myOA.shutdownObject(myGrid);
    System.out.println("**Grid server exiting**");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) com.hp.mwtests.ts.jts.orbspecific.resources.grid_i(com.hp.mwtests.ts.jts.orbspecific.resources.grid_i) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 57 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class StackServer method main.

public static void main(String[] args) throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    String refFile = args[0];
    stackPOATie theStack = new stackPOATie(new StackImple());
    myOA.objectIsReady(theStack);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(stackHelper.narrow(myOA.corbaReference(theStack))));
        System.out.println("Ready");
        myOA.run();
    } catch (Exception e) {
        TestUtility.fail("StackServer caught exception: " + e);
    }
    myOA.shutdownObject(theStack);
    System.out.println("**StackServer exiting**");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) StackImple(com.hp.mwtests.ts.jts.orbspecific.resources.StackImple) RootOA(com.arjuna.orbportability.RootOA) TestModule.stackPOATie(com.hp.mwtests.ts.jts.TestModule.stackPOATie) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 58 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class TimeoutClient method main.

public static void main(String[] args) throws Exception {
    ORB myORB = null;
    RootOA myOA = null;
    try {
        ServerORB orb = new ServerORB();
        myORB = orb.getORB();
        myOA = orb.getOA();
        CurrentImple current = OTSImpleManager.current();
        Control theControl = null;
        String objectReference = args[0];
        SetGet SetGetVar = null;
        System.out.println("Setting transaction timeout to " + timeout * mfactor + " seconds.");
        current.set_timeout(timeout * mfactor);
        current.begin();
        current.begin();
        long startTime = System.currentTimeMillis();
        try {
            Services serv = new Services(myORB);
            SetGetVar = SetGetHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(objectReference)));
        } catch (Exception e) {
            TestUtility.fail("Bind to object failed: " + e);
            e.printStackTrace(System.err);
        }
        try {
            theControl = current.get_control();
            SetGetVar.set((short) 2, theControl);
            theControl = null;
            System.out.println("Set value.");
        } catch (Exception e) {
            TestUtility.fail("Call to set or get failed: " + e);
            e.printStackTrace(System.err);
        }
        try {
            long timeNow = System.currentTimeMillis();
            long setTime = (timeNow - startTime);
            long timeoutTime = (timeout * 1000 * mfactor);
            long sleepTime = timeoutTime - setTime;
            if (sleepTime > 0) {
                System.out.println("Now sleeping for " + sleepTime * mfactor + " milliseconds.");
                Thread.sleep(sleepTime * mfactor);
            }
        } catch (Exception e) {
        }
        System.out.println("\ncommitting nested action.");
        try {
            current.commit(true);
            TestUtility.fail("commit worked");
        } catch (TRANSACTION_ROLLEDBACK e1) {
            System.out.println("Caught TransactionRolledBack");
        } catch (INVALID_TRANSACTION e1) /* For JacORB */
        {
            System.out.println("Caught InvalidTransaction");
        }
        System.out.println("\ncommitting top-level action");
        try {
            current.commit(true);
            TestUtility.fail("commit worked");
        } catch (TRANSACTION_ROLLEDBACK e2) {
            System.out.println("Caught TransactionRolledBack");
        } catch (INVALID_TRANSACTION e3) {
            System.out.println("Caught InvalidTransaction");
        } catch (Exception e) {
            TestUtility.fail("Caught other exception: " + e);
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
        TestUtility.fail(e.toString());
    }
    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) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) RootOA(com.arjuna.orbportability.RootOA) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 59 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class TMTest method test.

@Test
public void test() throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    TransactionFactory theOTS = null;
    Control topLevelControl = null;
    Services serv = new Services(myORB);
    int resolver = Services.getResolver();
    try {
        String[] params = new String[1];
        params[0] = Services.otsKind;
        org.omg.CORBA.Object obj = serv.getService(Services.transactionService, params, resolver);
        params = null;
        theOTS = TransactionFactoryHelper.narrow(obj);
    } catch (Exception e) {
        fail("Unexpected bind exception: " + e);
        e.printStackTrace(System.err);
    }
    System.out.println("Creating transaction.");
    try {
        topLevelControl = theOTS.create(0);
    } catch (Exception e) {
        fail("Create call failed: " + e);
        e.printStackTrace(System.err);
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : RootOA(com.arjuna.orbportability.RootOA) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) Control(org.omg.CosTransactions.Control) TransactionFactory(org.omg.CosTransactions.TransactionFactory) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 60 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class TranGridServer method test.

@Test
public void test() throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    String serverName = "TranGrid";
    String refFile = "/tmp/trangrid.ref";
    if (System.getProperty("os.name").startsWith("Windows")) {
        refFile = "C:\\temp\\trangrid.ref";
    }
    trangrid_i gridI = new trangrid_i((short) 100, (short) 100);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(gridI.getReference()));
        System.out.println("**TranGrid server started**");
        // assertReady();
        myOA.run();
    } catch (Exception e) {
        fail("TranGrid server caught exception: " + e);
    }
    myOA.shutdownObject(gridI);
    System.out.println("**TranGrid server exiting**");
}
Also used : com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i(com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Aggregations

ORB (com.arjuna.orbportability.ORB)70 RootOA (com.arjuna.orbportability.RootOA)70 Test (org.junit.Test)49 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)20 Services (com.arjuna.orbportability.Services)18 Control (org.omg.CosTransactions.Control)18 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)9 SystemException (org.omg.CORBA.SystemException)7 IntHolder (org.omg.CORBA.IntHolder)6 UserException (org.omg.CORBA.UserException)5 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 Terminator (org.omg.CosTransactions.Terminator)4 AtomicObject (com.hp.mwtests.ts.jts.orbspecific.resources.AtomicObject)3 Coordinator (org.omg.CosTransactions.Coordinator)3 Status (org.omg.CosTransactions.Status)3 TransactionFactory (org.omg.CosTransactions.TransactionFactory)3 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)2 TestResource (com.hp.mwtests.ts.jta.jts.common.TestResource)2 XACreator (com.hp.mwtests.ts.jta.jts.common.XACreator)2 SetGet (com.hp.mwtests.ts.jts.TestModule.SetGet)2