Search in sources :

Example 11 with ActivityHierarchy

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

the class CoordinatorControl method parentCoordinator.

private final BACoordinator parentCoordinator() throws SystemException {
    try {
        ActivityHierarchy hier = UserActivityFactory.userActivity().currentActivity();
        ActivityHandleImple parentActivity = null;
        BACoordinator parentCoordinator = null;
        if (hier.size() > 1) {
            parentActivity = (ActivityHandleImple) hier.activity(hier.size() - 2);
            parentCoordinator = (BACoordinator) _coordinators.get(parentActivity);
        }
        return parentCoordinator;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
Also used : ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) ActivityHandleImple(com.arjuna.mwlabs.wsas.activity.ActivityHandleImple) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) WrongStateException(com.arjuna.mw.wsas.exceptions.WrongStateException) ProtocolViolationException(com.arjuna.mw.wsas.exceptions.ProtocolViolationException)

Example 12 with ActivityHierarchy

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

the class CoordinatorControl method parentCoordinator.

private final ATCoordinator parentCoordinator() throws SystemException {
    try {
        ActivityHierarchy hier = UserActivityFactory.userActivity().currentActivity();
        ActivityHandleImple parentActivity = null;
        ATCoordinator parentCoordinator = null;
        if (hier.size() > 1) {
            parentActivity = (ActivityHandleImple) hier.activity(hier.size() - 2);
            parentCoordinator = (ATCoordinator) _coordinators.get(parentActivity);
        }
        return parentCoordinator;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
Also used : SubordinateATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) ActivityHandleImple(com.arjuna.mwlabs.wsas.activity.ActivityHandleImple) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) WrongStateException(com.arjuna.mw.wsas.exceptions.WrongStateException) ProtocolViolationException(com.arjuna.mw.wsas.exceptions.ProtocolViolationException)

Example 13 with ActivityHierarchy

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

the class SuspendTest method testSuspend.

@Test
public void testSuspend() 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.");
        }
    } catch (NoCoordinatorException ex) {
    // why is it ok to get here?
    } 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 14 with ActivityHierarchy

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

the class SuspendConfirmTest method testSuspendConfirm.

@Test
public void testSuspendConfirm() 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.");
        }
        ua.confirm();
    } catch (NoCoordinatorException ex) {
        // why is it ok to get here?
        WSCF11TestUtils.cleanup(ua);
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserCoordinator(com.arjuna.mw.wscf.model.twophase.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 15 with ActivityHierarchy

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

the class SuspendTest method testSuspend.

@Test
public void testSuspend() throws Exception {
    UserActivity ua = UserActivityFactory.userActivity();
    try {
        ua.start("dummy");
        System.out.println("Started: " + ua.activityName());
        ActivityHierarchy ctx = ua.suspend();
        System.out.println("\nSuspended: " + ctx);
        if (ua.currentActivity() != null) {
            fail("Current activity should be null " + ua.currentActivity());
        }
    } catch (Exception ex) {
        WSASTestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserActivity(com.arjuna.mw.wsas.UserActivity) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) 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