Search in sources :

Example 21 with ORB

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();
}
Also used : RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB)

Example 22 with ORB

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();
    }
}
Also used : OA(com.arjuna.orbportability.OA) RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB)

Example 23 with ORB

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();
}
Also used : RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 24 with ORB

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");
    }
}
Also used : Transaction(javax.transaction.Transaction) HashMap(java.util.HashMap) RootOA(com.arjuna.orbportability.RootOA) Properties(java.util.Properties) RecoveryManagerImple(com.arjuna.ats.internal.arjuna.recovery.RecoveryManagerImple) Synchronization(javax.transaction.Synchronization) Transaction(javax.transaction.Transaction) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 25 with ORB

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();
}
Also used : RootOA(com.arjuna.orbportability.RootOA) RollbackException(javax.transaction.RollbackException) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Aggregations

ORB (com.arjuna.orbportability.ORB)93 RootOA (com.arjuna.orbportability.RootOA)71 Test (org.junit.Test)57 OA (com.arjuna.orbportability.OA)20 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)20 Control (org.omg.CosTransactions.Control)20 Services (com.arjuna.orbportability.Services)19 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)9 PerfTestInterface (org.jboss.jbossts.qa.performance.PerfTestInterface)7 SystemException (org.omg.CORBA.SystemException)7 IntHolder (org.omg.CORBA.IntHolder)6 Coordinator (org.omg.CosTransactions.Coordinator)6 UserException (org.omg.CORBA.UserException)5 Properties (java.util.Properties)4 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 Terminator (org.omg.CosTransactions.Terminator)4 AtomicObject (com.hp.mwtests.ts.jts.orbspecific.resources.AtomicObject)3 Status (org.omg.CosTransactions.Status)3 TransactionFactory (org.omg.CosTransactions.TransactionFactory)3 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)2