{
boolean passed = false;
try
{
UserCoordinator ua = UserCoordinatorFactory.userCoordinator();
ua.start();
System.out.println("Started: "+ua.activityName());
ua.setCompletionStatus(Success.instance());
CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
cm.addParticipant(new DemoParticipant(true), Priorities.PARTICIPANT, null);
ua.start();
System.out.println("Started: "+ua.activityName());
ua.setCompletionStatus(Success.instance());
ContextManager manager = new ContextManager();
com.arjuna.mw.wsas.context.Context[] contexts = manager.contexts();
if (contexts != null)
{
for (int i = 0; i < contexts.length; i++)
System.out.println(contexts[i]);
}
cm.addParticipant(new FailureParticipant(false, FailureParticipant.TOPLEVEL_PREPARE), Priorities.PARTICIPANT, null);
Outcome res = ua.end();
if (res instanceof CoordinationOutcome)
{
CoordinationOutcome out = (CoordinationOutcome) res;
if (out.result() == TwoPhaseResult.CONFIRMED)
passed = true;
else
System.out.println("Result is: "+TwoPhaseResult.stringForm(out.result()));
}
else
System.out.println("Outcome is: "+res);
res = ua.end();
if (res instanceof CoordinationOutcome)
{
CoordinationOutcome out = (CoordinationOutcome) res;