Search in sources :

Example 11 with ControlImple

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

the class ContextManager method addControlImpleHierarchy.

/*
     * Given a ControlWrapper we can create the hierarchy quickly, since
     * we have the implementation information to hand.
     */
public final boolean addControlImpleHierarchy(ControlImple which) {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ContextManager::addControlImpleHierarchy ()");
    }
    boolean isError = false;
    try {
        ControlImple curr = which.getParentImple();
        Stack hier = new Stack();
        while (curr != null) {
            hier.push(new ControlWrapper(curr));
            curr = curr.getParentImple();
        }
        try {
            ControlWrapper wrapper = (ControlWrapper) hier.pop();
            while (wrapper != null) {
                pushAction(wrapper);
                wrapper = null;
                wrapper = (ControlWrapper) hier.pop();
            }
        } catch (EmptyStackException e) {
        }
    } catch (Exception e) {
        jtsLogger.i18NLogger.warn_context_genfail("ContextManager.addActionControlImple", e);
        isError = true;
    }
    return isError;
}
Also used : EmptyStackException(java.util.EmptyStackException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) SystemException(org.omg.CORBA.SystemException) EmptyStackException(java.util.EmptyStackException) Stack(java.util.Stack)

Example 12 with ControlImple

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

the class RestrictedInterposition method setupHierarchy.

/*
     * Assume that all actions in the imported hierarchy are of the same type,
     * i.e., all JBoss transactions. Because of the way garbage collection works
     * in the ORB we have to run an explicit garbage collection phase for
     * finished hierarchies.
     */
public synchronized ControlImple setupHierarchy(PropagationContext context) throws SystemException {
    ControlImple controlPtr = null;
    Uid theUid = null;
    ServerTopLevelAction proxyAction = null;
    if (context.parents.length == 0)
        theUid = Utility.otidToUid(context.current.otid);
    else
        theUid = Utility.otidToUid(context.parents[context.parents.length - 1].otid);
    proxyAction = super.present(theUid);
    if (proxyAction == null) {
        /*
             * Create a new proxyAction element and return the "current"
             * transaction.
             */
        controlPtr = createHierarchy(context, theUid);
    } else {
        /*
             * Check hierarchy of existing element.
             */
        controlPtr = checkHierarchy(proxyAction, context);
    }
    return controlPtr;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple)

Example 13 with ControlImple

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

the class ServerTopLevelRestrictedUnitTest 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());
    ServerRestrictedTopLevelAction act = new ServerRestrictedTopLevelAction(sc);
    assertTrue(act.type() != null);
    assertTrue(act.child() == null);
    assertTrue(act.deepestControl() != 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) ServerRestrictedTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.restricted.ServerRestrictedTopLevelAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 14 with ControlImple

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

the class ServerTopLevelStrictUnitTest 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());
    ServerStrictTopLevelAction act = new ServerStrictTopLevelAction(sc, true);
    assertTrue(act.interposeResource());
    assertTrue(act.type() != 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) ServerStrictTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictTopLevelAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 15 with ControlImple

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

the class ServerNestedRestrictedUnitTest 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());
    ServerRestrictedNestedAction act = new ServerRestrictedNestedAction(sc);
    assertTrue(act.deepestControl() != null);
    assertEquals(act.child(), 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) ServerRestrictedNestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.restricted.ServerRestrictedNestedAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Aggregations

ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)41 Test (org.junit.Test)30 Control (org.omg.CosTransactions.Control)24 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)21 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)19 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)10 Uid (com.arjuna.ats.arjuna.common.Uid)8 ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)7 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)7 PropagationContext (org.omg.CosTransactions.PropagationContext)5 SystemException (org.omg.CORBA.SystemException)4 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)3 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)3 ServerOSITopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction)3 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 GlobalTransactionInfo (com.arjuna.ArjunaOTS.GlobalTransactionInfo)2 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)2 ServerControlWrapper (com.arjuna.ats.internal.jts.interposition.ServerControlWrapper)2 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)2 ServerOSINestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction)2