Search in sources :

Example 6 with TransactionFactoryImple

use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.

the class OTSImpleManager method init.

private static final synchronized void init() {
    if (_current == null) {
        if (OTSImpleManager._theFactory == null) {
            /*
				 * Only check once, when the factory is first created.
				 */
            int resolver = Services.CONFIGURATION_FILE;
            boolean requireTransactionManager = false;
            if (jtsPropertyManager.getJTSEnvironmentBean().isTransactionManager()) {
                requireTransactionManager = true;
                String resolveMechanism = opPropertyManager.getOrbPortabilityEnvironmentBean().getResolveService();
                if (resolveMechanism.compareTo("NAME_SERVICE") == 0)
                    resolver = Services.NAME_SERVICE;
                else {
                    if (resolveMechanism.compareTo("BIND_CONNECT") == 0)
                        resolver = Services.BIND_CONNECT;
                }
            }
            if (requireTransactionManager) {
                try {
                    if (resolver != Services.BIND_CONNECT) {
                        String[] params = new String[1];
                        params[0] = Services.otsKind;
                        org.omg.CORBA.Object obj = ORBManager.getServices().getService(Services.transactionService, params, resolver);
                        params = null;
                        OTSImpleManager._theFactoryRef = org.omg.CosTransactions.TransactionFactoryHelper.narrow(obj);
                    } else {
                    }
                    if (OTSImpleManager._theFactoryRef == null)
                        throw new BAD_PARAM();
                } catch (InvalidName e1) {
                    jtsLogger.i18NLogger.warn_otsserverfailed(e1);
                    throw new FatalError(e1.toString(), e1);
                } catch (BAD_PARAM ex1) {
                    jtsLogger.i18NLogger.warn_otsserverfailed(ex1);
                    throw new FatalError(ex1.toString(), ex1);
                } catch (IOException e2) {
                    jtsLogger.i18NLogger.warn_otsservererror(e2);
                    throw new FatalError(e2.toString(), e2);
                } catch (SystemException e3) {
                    jtsLogger.i18NLogger.warn_otsservererror(e3);
                    throw new FatalError(e3.toString(), e3);
                } catch (UserException e4) {
                    jtsLogger.i18NLogger.warn_otsservererror(e4);
                    throw new FatalError(e4.toString(), e4);
                }
            } else {
                /* force to be local */
                OTSImpleManager._theFactory = new TransactionFactoryImple();
            }
        }
        if (OTSImpleManager._current == null) {
            try {
                OTSImpleManager._current = new CurrentImple();
                OTSImpleManager._currentRef = OTSImpleManager._current;
            } catch (Exception e) {
                OTSImpleManager._current = null;
                throw new com.arjuna.ats.arjuna.exceptions.FatalError("OTSImpleManager.current: " + e.toString(), e);
            }
        }
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) IOException(java.io.IOException) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) IOException(java.io.IOException) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) SystemException(org.omg.CORBA.SystemException) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) UserException(org.omg.CORBA.UserException)

Example 7 with TransactionFactoryImple

use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.

the class FactoryListUnitTest method test.

@SuppressWarnings("static-access")
@Test
public void test() throws Exception {
    FactoryList factory = new FactoryList();
    factory.removeDefault();
    try {
        assertNull(factory.recreate(null, FactoryList.DEFAULT_ID));
        fail();
    } catch (final INVALID_TRANSACTION ex) {
    } catch (final Throwable ex) {
        fail();
    }
    FactoryList.remove(Arjuna.restrictedXID());
    TransactionFactoryImple imple = new TransactionFactoryImple("test");
    ControlImple tx = imple.createLocal(1000);
    PropagationContext ctx = tx.get_coordinator().get_txcontext();
    Control cont = FactoryList.recreate(ctx, Arjuna.XID());
    assertTrue(Utility.getUid(cont).equals(tx.get_uid()));
}
Also used : Control(org.omg.CosTransactions.Control) PropagationContext(org.omg.CosTransactions.PropagationContext) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) FactoryList(com.arjuna.ats.internal.jts.interposition.FactoryList) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 8 with TransactionFactoryImple

use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.

the class ServerControlWrapperUnitTest method testEquality.

@Test
public void testEquality() throws Exception {
    TransactionFactoryImple imple = new TransactionFactoryImple("test");
    ControlImple tx = imple.createLocal(1000);
    ServerControlWrapper wrap1 = new ServerControlWrapper(tx);
    ServerControlWrapper wrap2 = new ServerControlWrapper(tx.getControl());
    assertTrue(wrap1.get_uid().equals(wrap2.get_uid()));
    wrap1 = new ServerControlWrapper(tx.getControl(), tx);
    wrap2 = new ServerControlWrapper(tx.getControl(), tx.get_uid());
    assertTrue(wrap1.get_uid().equals(wrap2.get_uid()));
}
Also used : ServerControlWrapper(com.arjuna.ats.internal.jts.interposition.ServerControlWrapper) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 9 with TransactionFactoryImple

use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.

the class ServerFactoryUnitTest method test.

@Test
public void test() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    ControlImple tx = factory.createLocal(1000);
    Uid u = new Uid();
    ServerControl server = ServerFactory.create_transaction(u, null, null, tx.get_coordinator(), tx.get_terminator(), 1000);
    try {
        ServerFactory.getCurrentStatus(new Uid("", false));
        Assert.fail();
    } catch (final Throwable ex) {
    }
    Assert.assertEquals(ServerFactory.getStatus(tx.get_uid()), org.omg.CosTransactions.Status.StatusActive);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 10 with TransactionFactoryImple

use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.

the class FactoryContactItemUnitTest method test.

@Test
public void test() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    assertTrue(FactoryContactItem.createAndSave(ArjunaFactoryHelper.narrow(factory.getReference())));
    FactoryContactItem item = FactoryContactItem.recreate(com.arjuna.ats.arjuna.utils.Utility.getProcessUid());
    assertTrue(item != null);
    assertTrue(item.getFactory() != null);
    item.markAsAlive();
    assertTrue(item.getAliveTime() != null);
    item.markAsDead();
    assertTrue(item.getCreationTime() != null);
    assertTrue(item.getUid() != Uid.nullUid());
}
Also used : TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) Test(org.junit.Test)

Aggregations

TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)15 Test (org.junit.Test)12 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)10 Control (org.omg.CosTransactions.Control)6 SystemException (org.omg.CORBA.SystemException)4 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)3 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)3 UserException (org.omg.CORBA.UserException)3 GlobalTransactionInfo (com.arjuna.ArjunaOTS.GlobalTransactionInfo)2 Uid (com.arjuna.ats.arjuna.common.Uid)2 ServerControlWrapper (com.arjuna.ats.internal.jts.interposition.ServerControlWrapper)2 ORB (com.arjuna.orbportability.ORB)2 RootOA (com.arjuna.orbportability.RootOA)2 NoTransaction (org.omg.CosTransactions.NoTransaction)2 PropagationContext (org.omg.CosTransactions.PropagationContext)2 Status (org.omg.CosTransactions.Status)2 Terminator (org.omg.CosTransactions.Terminator)2 CosTransactions.otid_t (org.omg.CosTransactions.otid_t)2 InterpositionFailed (com.arjuna.ArjunaOTS.InterpositionFailed)1 TransactionInfo (com.arjuna.ArjunaOTS.TransactionInfo)1