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");
}
}
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);
}
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**");
}
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**");
}
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.");
}
Aggregations