Search in sources :

Example 16 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class ServerControlUnitTest method test.

@Test
public void test() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    assertTrue(sc.isWrapper());
    assertTrue(sc.get_coordinator() != null);
    assertTrue(sc.get_terminator() != null);
    assertEquals(sc.getParentImple(), null);
    assertTrue(sc.forgetHeuristics());
    assertTrue(sc.toString() != null);
    sc.destroy();
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 17 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class ServerNestedOSIActionUnitTest method testCommit.

@Test
public void testCommit() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerOSINestedAction act = new ServerOSINestedAction(sc, true);
    assertFalse(act.interposeResource());
    act.commit_subtransaction(null);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ServerOSINestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 18 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class OTSThread method terminate.

/*
     * Can't use finalize since it may be called by
     * some other thread than this one.
     */
public void terminate() {
    try {
        CurrentImple current = OTSImpleManager.current();
        if (current != null) {
            Control c = current.suspend();
            c = null;
        }
    } catch (Exception e) {
    }
}
Also used : Control(org.omg.CosTransactions.Control) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple)

Example 19 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class ContextManagerUnitTest method testContextManager.

@Test
public void testContextManager() throws Exception {
    ContextManager manager = new ContextManager();
    assertEquals(manager.current(Thread.currentThread().getName()), null);
    assertEquals(manager.current(), null);
    OTSImpleManager.current().begin();
    manager.associate();
    OTSImpleManager.current().suspend();
    OTSImpleManager.current().begin();
    Control ct = OTSImpleManager.current().suspend();
    manager.addRemoteHierarchy(ct);
    manager.popAction();
    OTSImpleManager.current().suspend();
    OTSImpleManager.current().begin();
    ActionControl cont = (ActionControl) OTSImpleManager.current().getControlWrapper().getImple().getControl();
    manager.addActionControlHierarchy(cont);
    manager.purgeActions();
    OTSImpleManager.current().suspend();
    OTSImpleManager.current().begin();
    manager.addControlImpleHierarchy(OTSImpleManager.current().getControlWrapper().getImple());
    manager.purgeActions();
    OTSImpleManager.current().suspend();
}
Also used : Control(org.omg.CosTransactions.Control) ActionControl(com.arjuna.ArjunaOTS.ActionControl) ActionControl(com.arjuna.ArjunaOTS.ActionControl) ContextManager(com.arjuna.ats.internal.jts.context.ContextManager) Test(org.junit.Test)

Example 20 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class JtsTransactionImple method getTransactionIOR.

/**
 * If the current transaction represents an OTS transaction then return it IOR
 *
 * @return the IOR or null if the current transaction is not an OTS transaction
 * @throws NamingException
 * @throws org.omg.CORBA.SystemException
 * @throws SystemException
 * @throws Unavailable
 */
public static String getTransactionIOR() throws org.omg.CORBA.SystemException, SystemException, Unavailable {
    log.debug("getTransactionIOR");
    TransactionImpl curr = TransactionImpl.current();
    if (curr != null) {
        log.debug("have JtsTransactionImple");
        return curr.getControlIOR();
    } else if (hasTransaction()) {
        log.debug("have tx mgr");
        Transaction tx = tm.getTransaction();
        log.debug("have arjuna tx");
        TransactionImple atx = (TransactionImple) tx;
        ControlWrapper cw = atx.getControlWrapper();
        log.debug("lookup control");
        Control c = cw.get_control();
        String ior = ORBManager.getORB().orb().object_to_string(c);
        log.debug("getTransactionIOR: ior: " + ior);
        return ior;
    } else {
        return null;
    }
}
Also used : Control(org.omg.CosTransactions.Control) Transaction(javax.transaction.Transaction) AtomicTransaction(com.arjuna.ats.internal.jta.transaction.jts.AtomicTransaction) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionImpl(org.jboss.narayana.blacktie.jatmibroker.core.tx.TransactionImpl)

Aggregations

Control (org.omg.CosTransactions.Control)103 Test (org.junit.Test)40 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)24 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)20 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)20 ORB (com.arjuna.orbportability.ORB)20 RootOA (com.arjuna.orbportability.RootOA)18 TransactionFactory (org.omg.CosTransactions.TransactionFactory)16 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)14 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)13 Coordinator (org.omg.CosTransactions.Coordinator)13 SystemException (org.omg.CORBA.SystemException)11 IntHolder (org.omg.CORBA.IntHolder)10 Current (org.omg.CosTransactions.Current)9 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)6 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)6 Services (com.arjuna.orbportability.Services)6 PropagationContext (org.omg.CosTransactions.PropagationContext)6 ActionControl (com.arjuna.ArjunaOTS.ActionControl)5 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)5