Search in sources :

Example 1 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class ArjunaContextImple method initialiseContext.

public void initialiseContext(Object param) {
    try {
        BACoordinator currentCoordinator = (BACoordinator) param;
        ActivityHierarchy hier = null;
        try {
            hier = UserActivityFactory.userActivity().currentActivity();
        } catch (SystemException ex) {
            ex.printStackTrace();
        }
        if ((currentCoordinator != null) && (hier != null)) {
            /*
        		 * Do the manditory stuff first.
        		 */
            ActionHierarchy txHier = currentCoordinator.getHierarchy();
            final int depth = txHier.depth();
            _identifierValues = new String[depth];
            _expiresValues = new int[depth];
            _identifierValues[0] = txHier.getDeepestActionUid().stringForm();
            _expiresValues[0] = hier.activity(hier.size() - 1).getTimeout();
            /*
        		 * Now let's do the optional stuff.
        		 */
            for (int count = 1, index = 0; count < depth; count++, index++) {
                _identifierValues[count] = txHier.getActionUid(index).stringForm();
                _expiresValues[count] = hier.activity(index).getTimeout();
            }
        }
    } catch (ClassCastException ex) {
        throw new IllegalArgumentException();
    }
}
Also used : SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ActionHierarchy(com.arjuna.ats.arjuna.coordinator.ActionHierarchy) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) BACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.BACoordinator)

Example 2 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class SuspendResumeTest method testSuspendResume.

@Test
public void testSuspendResume() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    UserCoordinator ua = UserCoordinatorFactory.userCoordinator();
    try {
        ua.begin("TwoPhase11HLS");
        System.out.println("Started: " + ua.identifier() + "\n");
        ActivityHierarchy hier = ua.suspend();
        System.out.println("Suspended: " + hier + "\n");
        if (ua.currentActivity() != null) {
            WSCF11TestUtils.cleanup(ua);
            fail("Hierarchy still active");
        } else {
            ua.resume(hier);
            System.out.println("Resumed: " + hier + "\n");
            ua.cancel();
            System.out.println("Cancelled");
        }
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserCoordinator(com.arjuna.mw.wscf.model.twophase.api.UserCoordinator) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) Test(org.junit.Test)

Example 3 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class SuspendCloseTest method testSuspendClose.

@Test
public void testSuspendClose() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    UserCoordinator ua = UserCoordinatorFactory.userCoordinator();
    try {
        ua.begin("Sagas11HLS");
        System.out.println("Started: " + ua.identifier() + "\n");
        ActivityHierarchy hier = ua.suspend();
        System.out.println("Suspended: " + hier + "\n");
        if (ua.currentActivity() != null) {
            WSCF11TestUtils.cleanup(ua);
            fail("Hierarchy still active.");
        }
        ua.close();
    } catch (NoCoordinatorException ex) {
        WSCF11TestUtils.cleanup(ua);
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserCoordinator(com.arjuna.mw.wscf.model.sagas.api.UserCoordinator) NoCoordinatorException(com.arjuna.mw.wscf.exceptions.NoCoordinatorException) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) NoCoordinatorException(com.arjuna.mw.wscf.exceptions.NoCoordinatorException) Test(org.junit.Test)

Example 4 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class SuspendParticipantTest method testSuspendParticipant.

@Test
public void testSuspendParticipant() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
    try {
        cm.begin("TwoPhase11HLS");
        cm.enlistParticipant(new TwoPhaseParticipant("p1"));
        cm.enlistParticipant(new TwoPhaseParticipant("p2"));
        cm.enlistSynchronization(new TwoPhaseSynchronization());
        System.out.println("Started: " + cm.identifier() + "\n");
        ActivityHierarchy hier = cm.suspend();
        System.out.println("Suspended: " + hier + "\n");
        if (cm.currentActivity() != null) {
            WSCF11TestUtils.cleanup(cm);
            fail("Hierarchy still active.");
        }
        cm.resume(hier);
        System.out.println("Resumed: " + hier + "\n");
        cm.confirm();
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(cm);
        throw ex;
    }
}
Also used : TwoPhaseSynchronization(com.arjuna.wscf.tests.TwoPhaseSynchronization) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) CoordinatorManager(com.arjuna.mw.wscf.model.twophase.api.CoordinatorManager) TwoPhaseParticipant(com.arjuna.wscf.tests.TwoPhaseParticipant) Test(org.junit.Test)

Example 5 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class ResumeTest method testResume.

@Test
public void testResume() throws Exception {
    UserActivity ua = UserActivityFactory.userActivity();
    try {
        GlobalId ac1 = null;
        GlobalId ac2 = null;
        ua.start("dummy");
        ac1 = ua.activityId();
        System.out.println("Started: " + ac1);
        ua.start("dummy");
        ac2 = ua.activityId();
        System.out.println("\nStarted: " + ac2);
        ActivityHierarchy ctx = ua.suspend();
        System.out.println("\nSuspended: " + ctx);
        if (ua.currentActivity() != null) {
            fail("Current activity shoudl be null " + ua.currentActivity());
        }
        ua.resume(ctx);
        if (!ac2.equals(ua.activityId())) {
            fail("Current activity id " + ua.activityId() + " should equal " + ac2);
        }
        ua.end();
        if (!ac1.equals(ua.activityId())) {
            fail("Current activity id " + ua.activityId() + " should equal " + ac1);
        }
    } finally {
        WSASTestUtils.cleanup(ua);
    }
}
Also used : UserActivity(com.arjuna.mw.wsas.UserActivity) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) GlobalId(com.arjuna.mw.wsas.common.GlobalId) Test(org.junit.Test)

Aggregations

ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)20 Test (org.junit.Test)12 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)6 NoCoordinatorException (com.arjuna.mw.wscf.exceptions.NoCoordinatorException)4 UserActivity (com.arjuna.mw.wsas.UserActivity)3 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)3 UserCoordinator (com.arjuna.mw.wscf.model.sagas.api.UserCoordinator)3 UserCoordinator (com.arjuna.mw.wscf.model.twophase.api.UserCoordinator)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 ActionHierarchy (com.arjuna.ats.arjuna.coordinator.ActionHierarchy)2 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)2 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)2 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)2 CoordinatorManager (com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager)2 ActivityHandleImple (com.arjuna.mwlabs.wsas.activity.ActivityHandleImple)2 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)2 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)2 GlobalId (com.arjuna.mw.wsas.common.GlobalId)1 DuplicateParticipantException (com.arjuna.mw.wscf.exceptions.DuplicateParticipantException)1 CoordinatorManager (com.arjuna.mw.wscf.model.twophase.api.CoordinatorManager)1