myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
CurrentImple current = OTSImpleManager.current();
AtomicResource aImpl = new AtomicResource(shouldCommit);
Resource atomicObject = aImpl.getReference();
System.out.println("beginning top-level transaction.");
current.begin();
Control myControl = current.get_control();
if (myControl == null)
{
System.err.println("Error - myControl is nil");
System.exit(0);
}
System.out.println("getting coordinator");
coord = myControl.get_coordinator();
myControl = null;
System.out.println("registering resources.");
RecoveryCoordinator rc = null;
try
{
rc = coord.register_resource(atomicObject);
}
catch (Exception ex)
{
System.out.println("Failed to register resources: "+ex);
ex.printStackTrace();
System.exit(0);
}
if (rc == null)
System.out.println("No recovery coordinator reference.");
else
{
Status s = Status.StatusUnknown;
try
{
System.out.println("Attempting to use recovery coordinator.");
s = rc.replay_completion(atomicObject);
}
catch (NotPrepared e)
{
s = Status.StatusActive;
}
catch (Exception ex)
{
System.err.println("Caught: "+ex);
ex.printStackTrace();
System.exit(0);
}
System.out.println("Got: "+com.arjuna.ats.jts.utils.Utility.stringStatus(s));
if (s == Status.StatusActive)
passed = true;
}
System.out.println("committing top-level transaction.");
if (shouldCommit)
current.commit(true);
else
current.rollback();
if (rc == null)
System.out.println("No recovery coordinator reference.");
else
{