if (operationsLogger.isLoggable(Level.FINER)) {
operationsLogger.entering(PrepareJob.class.getName(),
"doWork", new Object[] {who, param});
}
ParticipantHandle handle = (ParticipantHandle)param;
TransactionParticipant par = null;
//check if a vote already exists because it was
//recovered from the log. In this situation,
//we do not need to log this info since it
//exists in the log which was used for recovery...
int vote = handle.getPrepState();
switch (vote) {
case COMMITTED:
case NOTCHANGED:
case ABORTED:
case PREPARED:
if (operationsLogger.isLoggable(Level.FINER)) {
operationsLogger.exiting(
PrepareJob.class.getName(),
"doWork", new Integer(vote));
}
return new Integer(vote);
}
//...otherwise, explicitly instruct the participant to
//prepare after unpacking it and checking against the
//max retry threshold
if (par == null)
par = handle.getPreParedParticipant();
//If you have exhausted the max retry threshold
//stop, so that no further attempts are made.
try {
if (attempt(who) > maxtries) {
if (operationsLogger.isLoggable(Level.FINER)) {
operationsLogger.exiting(
PrepareJob.class.getName(),"doWork",
new Integer(ABORTED));
}
return new Integer(ABORTED);
}
} catch (JobException je) {
if (operationsLogger.isLoggable(Level.FINER)) {
operationsLogger.exiting(
PrepareJob.class.getName(),"doWork", null);
}
return null;
}
//At this point, if participant is null, there
//must be an error unpacking, so retry later
if (par == null) {
if (operationsLogger.isLoggable(Level.FINER)) {
operationsLogger.exiting(
PrepareJob.class.getName(),"doWork", null);
}
return null;
}
//Here we actually need to ask the participant to
//prepare. Note the RemoteException causes a
//retry. Here we only log info for the cases
//where a final outcome is available.
Object response = null;
try {
vote = par.prepare(tr.mgr, tr.id);
response = new Integer(vote);
} catch (TransactionException bte) {
vote = ABORTED;
response = new Integer(vote);
} catch (RemoteException re) {