Search in sources :

Example 21 with Services

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

the class CurrentTest 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 myControl = null;
    String gridReference = args[0];
    // pointer the grid object that will be used.
    grid gridVar = null;
    int h = -1, w = -1, v = -1;
    System.out.println("Beginning transaction.");
    try {
        current.begin();
        myControl = current.get_control();
        TestUtility.assertTrue(myControl != null);
    } catch (Exception sysEx) {
        sysEx.printStackTrace(System.err);
        TestUtility.fail(sysEx.toString());
    }
    try {
        Services serv = new Services(myORB);
        gridVar = gridHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(gridReference)));
    } catch (Exception sysEx) {
        TestUtility.fail("failed to bind to grid: " + sysEx);
        sysEx.printStackTrace(System.err);
    }
    try {
        h = gridVar.height();
        w = gridVar.width();
    } catch (Exception sysEx) {
        TestUtility.fail("grid height/width failed: " + sysEx);
        sysEx.printStackTrace(System.err);
    }
    System.out.println("height is " + h);
    System.out.println("width  is " + w);
    try {
        gridVar.set(2, 4, 123, myControl);
        v = gridVar.get(2, 4, myControl);
    } catch (Exception sysEx) {
        TestUtility.fail("grid set/get failed: " + sysEx);
        sysEx.printStackTrace(System.err);
    }
    // no problem setting and getting the element:
    System.out.println("grid[2,4] is " + v);
    // sanity check: make sure we got the value 123 back:
    if (v != 123) {
        TestUtility.fail("something went seriously wrong");
        try {
            current.rollback();
        } catch (Exception e) {
            TestUtility.fail("rollback error: " + e);
            e.printStackTrace(System.err);
        }
    } else {
        System.out.println("Committing transaction.");
        try {
            current.commit(true);
        } catch (Exception e) {
            TestUtility.fail("commit error: " + e);
            e.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) TestModule.grid(com.hp.mwtests.ts.jts.TestModule.grid) 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

Services (com.arjuna.orbportability.Services)21 ORB (com.arjuna.orbportability.ORB)19 RootOA (com.arjuna.orbportability.RootOA)18 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)16 Control (org.omg.CosTransactions.Control)6 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)5 Test (org.junit.Test)5 IntHolder (org.omg.CORBA.IntHolder)5 TransactionFactory (org.omg.CosTransactions.TransactionFactory)3 SetGet (com.hp.mwtests.ts.jts.TestModule.SetGet)2 TestModule.grid (com.hp.mwtests.ts.jts.TestModule.grid)2 com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i (com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i)2 OA (com.arjuna.orbportability.OA)1 SimpleObjectImpl (com.hp.mwtests.orbportability.orbspecific.orbinstance.SimpleObjectImpl)1 ExplicitStackPOATie (com.hp.mwtests.ts.jts.TestModule.ExplicitStackPOATie)1 HammerPOATie (com.hp.mwtests.ts.jts.TestModule.HammerPOATie)1 TranGrid (com.hp.mwtests.ts.jts.TestModule.TranGrid)1 TestModule.stack (com.hp.mwtests.ts.jts.TestModule.stack)1 TestModule.stackPOATie (com.hp.mwtests.ts.jts.TestModule.stackPOATie)1 DHThreadObject2 (com.hp.mwtests.ts.jts.orbspecific.resources.DHThreadObject2)1