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();
}
}
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;
}
}
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;
}
}
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;
}
}
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);
}
}
Aggregations