new Node(HEAD, -1); // create the head node
}
public void add(Integer value) throws Throwable{
Throwable throwable = null;
Context context = ContextDelegator.getInstance();
boolean commit = true;
for (int i = 0; i < 0x7fffffff; i++) {
context.init(3);
try {
add(value, 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.");
}