{
boolean passed = false;
try
{
CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
cm.begin();
cm.enlistParticipant(new TwoPhaseParticipant(null));
cm.enlistParticipant(new TwoPhaseParticipant(null));
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)
{
System.out.println("Hierarchy still active.");
cm.cancel();
}
else
{
System.out.println("Resumed: "+hier+"\n");
cm.resume(hier);
cm.confirm();
passed = true;
}
}
catch (Exception ex)