use of com.arjuna.orbportability.RootOA 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");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class DistributedHammer1 method main.
public static void main(String[] args) throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String server1 = args[0];
String server2 = args[1];
try {
Services serv = new Services(myORB);
DistributedHammerWorker1.hammerObject_1 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server1)));
DistributedHammerWorker1.hammerObject_2 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server2)));
TestUtility.assertTrue(DistributedHammerWorker1.hammerObject_1.set(START_VALUE_1, null));
TestUtility.assertTrue(DistributedHammerWorker1.hammerObject_2.set(START_VALUE_2, null));
DistributedHammerWorker1.get12('m', 0);
DistributedHammerWorker1.get21('m', 0);
} catch (Exception e) {
TestUtility.fail("DistributedHammer1: " + e);
e.printStackTrace(System.err);
}
for (int i = 0; i < 100; i++) DistributedHammerWorker1.randomOperation('1', 0);
DistributedHammerWorker1.get12('m', 0);
DistributedHammerWorker1.get21('m', 0);
IntHolder value1 = new IntHolder(0);
IntHolder value2 = new IntHolder(0);
TestUtility.assertTrue(DistributedHammerWorker1.get1(value1) | DistributedHammerWorker1.get2(value2));
TestUtility.assertEquals(EXPECTED_RESULT, (value1.value + value2.value));
myOA.destroy();
myORB.shutdown();
System.out.println("Passed");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class DistributedHammer3 method main.
public static void main(String[] args) throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String server1 = args[0];
String server2 = args[1];
try {
Services serv = new Services(myORB);
DistributedHammerWorker3.hammerObject_1 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server1)));
DistributedHammerWorker3.hammerObject_2 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server2)));
TestUtility.assertTrue(DistributedHammerWorker3.hammerObject_1.set(START_VALUE_1, null));
TestUtility.assertTrue(DistributedHammerWorker3.hammerObject_2.set(START_VALUE_2, null));
DistributedHammerWorker3.get12(0, 0);
DistributedHammerWorker3.get21(0, 0);
} catch (Exception e) {
TestUtility.fail("DistributedHammer3: " + e);
e.printStackTrace(System.err);
}
DHThreadObject3b thr1 = new DHThreadObject3b(1);
DHThreadObject3b thr2 = new DHThreadObject3b(2);
thr1.start();
thr2.start();
try {
thr1.join();
thr2.join();
} catch (InterruptedException e) {
System.err.println(e);
}
DistributedHammerWorker3.get12(0, 0);
DistributedHammerWorker3.get21(0, 0);
IntHolder value1 = new IntHolder(0);
IntHolder value2 = new IntHolder(0);
TestUtility.assertTrue(DistributedHammerWorker3.get1(value1) | DistributedHammerWorker3.get2(value2));
TestUtility.assertEquals(EXPECTED_RESULT, (value1.value + value2.value));
myOA.destroy();
myORB.shutdown();
System.out.println("Passed");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class ImplGridServer 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];
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("Ready");
myOA.run();
} catch (Exception e) {
TestUtility.fail("ImplGrid server caught exception: " + e);
}
myOA.shutdownObject(gridI);
System.out.println("**ImplGrid server exiting**");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class SimpleTest 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);
jtaPropertyManager.getJTAEnvironmentBean().setTransactionManagerClassName(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple.class.getName());
jtaPropertyManager.getJTAEnvironmentBean().setUserTransactionClassName(com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple.class.getName());
javax.transaction.TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
transactionManager.begin();
Transaction currentTrans = transactionManager.getTransaction();
TestResource res1, res2;
currentTrans.enlistResource(res1 = new TestResource());
currentTrans.enlistResource(res2 = new TestResource());
currentTrans.delistResource(res2, XAResource.TMSUCCESS);
currentTrans.delistResource(res1, XAResource.TMSUCCESS);
transactionManager.commit();
myOA.destroy();
myORB.shutdown();
}
Aggregations