use of org.omg.CosTransactions.TransactionFactory in project narayana by jbosstm.
the class Client05 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
TransactionFactory transactionFactory = null;
String[] transactionFactoryParams = new String[1];
transactionFactoryParams[0] = ORBServices.otsKind;
transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
boolean correct;
Control control = transactionFactory.create(4);
Thread.sleep(8000);
try {
control.get_terminator().commit(false);
correct = false;
} catch (INVALID_TRANSACTION invalidTransaction) {
correct = true;
} catch (BAD_OPERATION badOperation) {
correct = true;
} catch (org.omg.CORBA.OBJECT_NOT_EXIST object_not_exist_exception) {
// This test creates a transaction with timeout period of 4 seconds then
// sleeps for 8 seconds.
// When the timeout goes off at the transaction service, the transaction is
// rolled back and destroyed.
// The subsequent call to commit on the transaction results in an
// org.omg.CORBA.OBJECT_NOT_EXIST exception being thrown.
// The JTS specification appears to be quite vague in this area, however our
// implementation is compliant with this vagueness.
// Hence, For the purposes of this test, org.omg.CORBA.OBJECT_NOT_EXIST being thrown
// does not indicate a failure - BD 20/06/01
correct = true;
} catch (Exception exception) {
System.err.println("Client05.main: commit exception = " + exception);
correct = false;
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client05.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client05.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CosTransactions.TransactionFactory in project narayana by jbosstm.
the class Client11 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
TransactionFactory transactionFactory = null;
String[] transactionFactoryParams = new String[1];
transactionFactoryParams[0] = ORBServices.otsKind;
transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
int numberOfControls = Integer.parseInt(args[args.length - 1]);
boolean correct = true;
Control[] controls = new Control[numberOfControls];
for (int index = 0; correct && (index < controls.length); index++) {
controls[index] = transactionFactory.create(0);
correct = correct && (controls[index].get_coordinator().get_status() == Status.StatusActive);
}
for (int index = 0; correct && (index < controls.length); index++) {
controls[index].get_terminator().commit(false);
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client11.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client11.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CosTransactions.TransactionFactory in project narayana by jbosstm.
the class Client08 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
TransactionFactory transactionFactory = null;
String[] transactionFactoryParams = new String[1];
transactionFactoryParams[0] = ORBServices.otsKind;
transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
int numberOfControls = Integer.parseInt(args[args.length - 1]);
boolean correct = true;
for (int index = 0; correct && (index < numberOfControls); index++) {
Control control = transactionFactory.create(0);
correct = correct && (control.get_coordinator().get_status() == Status.StatusActive);
control.get_terminator().commit(false);
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client08.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client08.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CosTransactions.TransactionFactory in project narayana by jbosstm.
the class Client12 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
TransactionFactory transactionFactory = null;
String[] transactionFactoryParams = new String[1];
transactionFactoryParams[0] = ORBServices.otsKind;
transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
int numberOfControls = Integer.parseInt(args[args.length - 1]);
boolean correct = true;
Control[] controls = new Control[numberOfControls];
for (int index = 0; correct && (index < controls.length); index++) {
controls[index] = transactionFactory.create(0);
correct = correct && (controls[index].get_coordinator().get_status() == Status.StatusActive);
}
for (int index = 0; correct && (index < controls.length); index++) {
controls[index].get_terminator().rollback();
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client12.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client12.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CosTransactions.TransactionFactory in project narayana by jbosstm.
the class Client14 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
TransactionFactory transactionFactory = null;
String[] transactionFactoryParams = new String[1];
transactionFactoryParams[0] = ORBServices.otsKind;
transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
int numberOfWorkers = Integer.parseInt(args[args.length - 2]);
int numberOfControls = Integer.parseInt(args[args.length - 1]);
boolean correct = true;
Worker[] workers = new Worker[numberOfWorkers];
for (int index = 0; index < workers.length; index++) {
workers[index] = new Worker(numberOfControls, transactionFactory);
}
for (int index = 0; index < workers.length; index++) {
workers[index].start();
}
for (int index = 0; index < workers.length; index++) {
workers[index].join();
correct = correct && workers[index].isCorrect();
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client14.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client14.main: " + exception);
exception.printStackTrace(System.err);
}
}
Aggregations