public class Vacation {
public static void makeReservation(String customerId, int[] objType, String[] objId) throws Throwable{
Throwable throwable = null;
Context context = ContextDelegator.getInstance();
boolean commit = true;
for (int i = 0; i < 0x7fffffff; i++) {
context.init(3);
try {
makeReservation(customerId, objType, objId, context);
} catch (TransactionException ex) {
commit = false;
} catch (Throwable ex) {
throwable = ex;
}
if (commit) {
if (context.commit()) {
if (throwable != null) {
throw throwable;
} else {
return;
}
}
} else {
if(context instanceof ControlContext)
ControlContext.abort(((ControlContext)context).getContextId());
else
context.rollback();
commit = true;
}
}
throw new TransactionException("Failed to commit the transaction in the defined retries.");
}