Search in sources :

Example 1 with Services

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

the class SetupOTSServer2 method main.

public static void main(String[] args) {
    String bindName = System.getProperty(NAME_SERVICE_BIND_NAME_PROPERTY);
    if (bindName != null) {
        System.out.println("Looking up OTS Server '" + bindName + "'");
        try {
            String transactionServiceIOR = getService(bindName);
            ORBInterface.initORB(args, null);
            String[] transactionFactoryParams = new String[1];
            transactionFactoryParams[0] = ORBServices.otsKind;
            Services services = new Services(ORBInterface.getORB());
            services.registerService(ORBInterface.orb().string_to_object(transactionServiceIOR), ORBServices.transactionService, transactionFactoryParams);
            System.out.println("Ready");
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.out.println("Failed");
        }
    } else {
        System.out.println("Bind name '" + NAME_SERVICE_BIND_NAME_PROPERTY + "' not specified");
        System.out.println("Failed");
    }
}
Also used : Services(com.arjuna.orbportability.Services) IOException(java.io.IOException)

Example 2 with Services

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

the class ServiceTestSetup method test.

@Test
public void test() throws Exception {
    /**
     * Create ORB and OA *
     */
    ORB testORB = ORB.getInstance(ORB_INSTANCE_NAME);
    OA testOA = OA.getRootOA(testORB);
    /**
     * Initialise ORB and OA *
     */
    testORB.initORB(new String[] {}, null);
    testOA.initPOA(new String[] {});
    /**
     * Create services object *
     */
    Services testServ = new Services(testORB);
    String[] params = new String[1];
    params[0] = com.arjuna.orbportability.Services.otsKind;
    SimpleObjectImpl servant = new com.hp.mwtests.orbportability.orbspecific.orbinstance.SimpleObjectImpl();
    testOA.objectIsReady(servant);
    /*
			 * Register using the default mechanism.
			 */
    testServ.registerService(com.hp.mwtests.orbportability.orbspecific.orbtests.SimpleObjectHelper.narrow(testOA.corbaReference(servant)), TEST_SERVICE_NAME, params, Services.CONFIGURATION_FILE);
}
Also used : Services(com.arjuna.orbportability.Services) OA(com.arjuna.orbportability.OA) SimpleObjectImpl(com.hp.mwtests.orbportability.orbspecific.orbinstance.SimpleObjectImpl) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 3 with Services

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

the class ExplicitStackServer 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];
    ExplicitStackPOATie theObject = new ExplicitStackPOATie(new ExplicitStackImple());
    myOA.objectIsReady(theObject);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(myOA.corbaReference(theObject)));
        System.out.println("Ready");
        myOA.run();
    } catch (Exception e) {
        e.printStackTrace();
    }
    myOA.shutdownObject(theObject);
    System.out.println("**ExplicitStackServer exiting**");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ExplicitStackImple(com.hp.mwtests.ts.jts.orbspecific.resources.ExplicitStackImple) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) ExplicitStackPOATie(com.hp.mwtests.ts.jts.TestModule.ExplicitStackPOATie) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 4 with Services

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

the class HammerServer 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];
    HammerPOATie theObject = new HammerPOATie(new HammerObject());
    myOA.objectIsReady(theObject);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(HammerHelper.narrow(myOA.corbaReference(theObject))));
        System.out.println("\nIOR file: " + refFile);
        System.out.println("Ready");
        // assertReady();
        myOA.run();
    } catch (Exception e) {
        // fail("HammerServer caught exception: "+e);
        e.printStackTrace(System.err);
    }
    myOA.shutdownObject(theObject);
    System.out.println("**HammerServer exiting**");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) HammerPOATie(com.hp.mwtests.ts.jts.TestModule.HammerPOATie) HammerObject(com.hp.mwtests.ts.jts.orbspecific.resources.HammerObject) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 5 with Services

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

the class GridClient 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);
    TransactionFactory theOTS = null;
    Control myControl = null;
    grid gridVar = null;
    int h = -1, w = -1, v = -1;
    String gridReference = "/tmp/grid.ref";
    String serverName = "Grid";
    if (System.getProperty("os.name").startsWith("Windows")) {
        gridReference = "C:\\temp\\grid.ref";
    }
    Services serv = new Services(myORB);
    try {
        String[] params = new String[1];
        params[0] = Services.otsKind;
        org.omg.CORBA.Object obj = serv.getService(Services.transactionService, params);
        params = null;
        theOTS = TransactionFactoryHelper.narrow(obj);
    } catch (Exception e) {
        fail("Unexpected bind exception: " + e);
    }
    System.out.println("Creating transaction.");
    try {
        myControl = theOTS.create(0);
    } catch (Exception e) {
        fail("Create call failed: " + e);
        e.printStackTrace();
    }
    try {
        gridVar = gridHelper.narrow(serv.getService(gridReference, null, Services.FILE));
    } catch (Exception e) {
        fail("Grid bind failed: " + e);
    }
    try {
        h = gridVar.height();
        w = gridVar.width();
    } catch (Exception e) {
        fail("Grid invocation failed: " + e);
    }
    System.out.println("height is " + h);
    System.out.println("width  is " + w);
    try {
        System.out.println("calling set");
        gridVar.set(2, 4, 123, myControl);
        System.out.println("calling get");
        v = gridVar.get(2, 4, myControl);
    } catch (Exception sysEx) {
        fail("Grid set/get failed: " + sysEx);
    }
    // no problem setting and getting the elememt:
    System.out.println("grid[2,4] is " + v);
    // sanity check: make sure we got the value 123 back:
    if (v != 123) {
        // oops - we didn't:
        fail("something went seriously wrong");
        try {
            myControl.get_terminator().rollback();
        } catch (Exception e) {
        }
    } else {
        System.out.println("Committing transaction.");
        try {
            Terminator handle = myControl.get_terminator();
            handle.commit(true);
        } catch (Exception sysEx) {
            fail("Transaction commit error: " + sysEx);
        }
    }
    try {
        OTSManager.destroyControl(myControl);
    } catch (Exception e) {
        fail("Caught destroy exception: " + e);
    }
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Test completed successfully.");
}
Also used : RootOA(com.arjuna.orbportability.RootOA) Terminator(org.omg.CosTransactions.Terminator) Services(com.arjuna.orbportability.Services) Control(org.omg.CosTransactions.Control) TestModule.grid(com.hp.mwtests.ts.jts.TestModule.grid) TransactionFactory(org.omg.CosTransactions.TransactionFactory) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

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