use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class TransactionServer method doWork.
static void doWork(String[] args, boolean exitOnComplete) throws Exception {
String refFile = com.arjuna.orbportability.Services.transactionService;
String objectName = null;
boolean printReady = false;
ORB myORB = null;
RootOA myOA = null;
for (int i = 0; i < args.length; i++) {
if (args[i].compareTo("-otsname") == 0)
objectName = args[i + 1];
if (args[i].compareTo("-test") == 0)
printReady = true;
if (args[i].compareTo("-help") == 0) {
System.out.println("Usage: [-otsname <name>] [-help] [-version] [-recovery]");
if (exitOnComplete)
return;
else
System.exit(0);
}
if (args[i].compareTo("-version") == 0) {
System.out.println("TransactionServer version " + ConfigurationInfo.getVersion());
if (exitOnComplete)
return;
else
System.exit(0);
}
if (args[i].compareTo("-recovery") == 0) {
RecoveryManager.manager().startRecoveryManagerThread();
}
}
com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple theOTS = null;
final int resolver = Services.getResolver();
try {
try {
myORB = ORB.getInstance("TransactionServer");
myOA = OA.getRootOA(myORB);
myORB.initORB(args, null);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
} catch (Exception e) {
System.err.println("Initialisation of TransactionServer failed: " + e);
throw e;
}
theOTS = new com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple(objectName);
try {
registerTransactionManager(resolver, myORB, theOTS.getReference());
if (!printReady)
System.out.println("Transaction manager registered.");
} catch (Exception e1) {
System.err.println("Failed to bind transaction manager: " + e1);
if (exitOnComplete)
throw new Exception("Failed to bind transaction manager:" + e1);
else
System.exit(0);
}
if (printReady)
System.out.println("Ready");
else
System.out.println("JBossTS OTS Server startup.");
if (!exitOnComplete) {
if (resolver == com.arjuna.orbportability.Services.BIND_CONNECT)
myOA.run(com.arjuna.orbportability.Services.transactionService);
else
myOA.run();
}
} catch (Exception e2) {
System.err.println("TransactionServer caught exception " + e2);
}
System.out.println("JBossTS OTS Server shutdown");
theOTS = null;
if (myOA != null)
myOA.destroy();
if (myORB != null)
myORB.shutdown();
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class ORBSetup method invoke.
/**
* This method is invoked when the ORB is initialised
*/
public void invoke(Object obj) {
if (!ORBManager.isInitialised()) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("The ORBSetup.invoke method has been invoked");
}
/**
* If the object passed in is an ORB Portability ORB
* then set it to be the ORB used by the JTS.
*/
if (obj instanceof ORB) {
ORB orb = (ORB) obj;
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("The JTS ORB has been set to " + orb);
}
/**
* Set the orb manager and then set the POA to be the root POA for
* that ORB. If another POA is then initialised this will be overridden.
*/
ORBManager.setORB(orb);
ORBManager.setPOA(RootOA.getRootOA(orb));
}
/**
* If the object passed in is an ORB Portability OA
* then set it to be the OA used by the JTS.
*/
if (obj instanceof OA) {
OA oa = (OA) obj;
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("The JTS OA has been set " + oa);
}
ORBManager.setPOA(oa);
}
} else {
jtsLogger.i18NLogger.info_utils_ORBSetup_orbalreadyset();
}
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class XAResourceTest method testTwoResourcesReturnXA_RDONLY.
@Test
public void testTwoResourcesReturnXA_RDONLY() throws Exception {
ORB myORB = ORB.getInstance("test");
RootOA myOA = OA.getRootOA(myORB);
myORB.initORB(new String[] {}, null);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
RecoveryManager.manager();
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
tm.begin();
javax.transaction.Transaction theTransaction = tm.getTransaction();
assertTrue(theTransaction.enlistResource(new XA_READONLYXAResource()));
assertTrue(theTransaction.enlistResource(new XA_READONLYXAResource()));
assertTrue(theTransaction.enlistResource(new XA_READONLYXAResource()));
tm.commit();
RecoveryManager.manager().terminate();
myOA.destroy();
myORB.shutdown();
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class JTSSynchronizationTest method test.
@Test
public void test() throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("com.arjuna.orbportability.orb.PreInit1", "com.arjuna.ats.internal.jts.context.ContextPropagationManager");
map.put("com.arjuna.orbportability.orb.PostInit", "com.arjuna.ats.jts.utils.ORBSetup");
map.put("com.arjuna.orbportability.orb.PostInit2", "com.arjuna.ats.internal.jts.recovery.RecoveryInit");
map.put("com.arjuna.orbportability.orb.PostSet1", "com.arjuna.ats.jts.utils.ORBSetup");
opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(map);
ORB myORB = ORB.getInstance("test");
RootOA myOA = OA.getRootOA(myORB);
final Properties initORBProperties = new Properties();
initORBProperties.setProperty("com.sun.CORBA.POA.ORBServerId", "1");
initORBProperties.setProperty("com.sun.CORBA.POA.ORBPersistentServerPort", "" + jtsPropertyManager.getJTSEnvironmentBean().getRecoveryManagerPort());
myORB.initORB(new String[] {}, initORBProperties);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryActivatorClassNames(Arrays.asList(new String[] { "com.arjuna.ats.internal.jts.orbspecific.recovery.RecoveryEnablement" }));
final TransactionSynchronizationRegistry tsr = new com.arjuna.ats.internal.jta.transaction.jts.TransactionSynchronizationRegistryImple();
new RecoveryManagerImple(false);
final javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
tm.getStatus();
tm.begin();
javax.transaction.Transaction theTransaction = tm.getTransaction();
assertTrue(theTransaction.enlistResource(new XARMERRXAResource(false)));
assertTrue(theTransaction.enlistResource(new XARMERRXAResource(false)));
tsr.registerInterposedSynchronization(new Synchronization() {
@Override
public void beforeCompletion() {
}
@Override
public void afterCompletion(int arg0) {
try {
Transaction transaction = tm.getTransaction();
Transaction suspend = tm.suspend();
assertTrue(tm.getStatus() == javax.transaction.Status.STATUS_NO_TRANSACTION);
Transaction suspend2 = tm.suspend();
assertTrue(suspend2 == null);
tm.begin();
assertTrue(tm.getStatus() == javax.transaction.Status.STATUS_ACTIVE);
tm.commit();
assertTrue(tm.getStatus() == javax.transaction.Status.STATUS_NO_TRANSACTION);
tm.resume(suspend);
assertTrue(tm.getStatus() == arg0);
Transaction transaction2 = tm.getTransaction();
assertTrue(transaction == transaction2);
} catch (SystemException | IllegalStateException | SecurityException | InvalidTransactionException | NotSupportedException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) {
failed = true;
e.printStackTrace();
}
}
});
tm.commit();
myOA.destroy();
myORB.shutdown();
if (failed) {
fail("Issues");
}
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class XAResourceCheckForSingleEndCall method test.
@Test
public void test() throws Exception {
ORB myORB = ORB.getInstance("test");
RootOA 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());
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
tm.begin();
javax.transaction.Transaction theTransaction = tm.getTransaction();
XARMFAILXAResource xarmfailxaResource = new XARMFAILXAResource(true);
XARMFAILXAResource xarmfailxaResource2 = new XARMFAILXAResource(false);
assertTrue(theTransaction.enlistResource(xarmfailxaResource));
assertTrue(theTransaction.enlistResource(xarmfailxaResource2));
try {
tm.commit();
fail("Should have failed");
} catch (RollbackException e) {
// Expected
}
assertTrue(xarmfailxaResource.rollbackCalled = true);
assertTrue(xarmfailxaResource2.rollbackCalled = true);
assertTrue(xarmfailxaResource.endCount == 1);
assertTrue(xarmfailxaResource2.endCount == 1);
myOA.destroy();
myORB.shutdown();
}
Aggregations