localTxContext.setLocalTransaction(localTransaction);
}
}
private Object enlistWriteAndInvokeNext(InvocationContext ctx, WriteCommand command) throws Throwable {
LocalTransaction localTransaction = null;
boolean shouldAddMod = false;
if (shouldEnlist(ctx)) {
localTransaction = enlist((TxInvocationContext) ctx);
LocalTxInvocationContext localTxContext = (LocalTxInvocationContext) ctx;
if (localModeNotForced(command)) shouldAddMod = true;
localTxContext.setLocalTransaction(localTransaction);
}
Object rv;
try {
rv = invokeNextInterceptor(ctx, command);
} catch (Throwable throwable) {
// Don't mark the transaction for rollback if it's fail silent (i.e. putForExternalRead)
if (ctx.isOriginLocal() && ctx.isInTxScope() && !command.hasFlag(Flag.FAIL_SILENTLY)) {
TxInvocationContext txCtx = (TxInvocationContext) ctx;
txCtx.getTransaction().setRollbackOnly();
}
throw throwable;
}
if (command.isSuccessful() && shouldAddMod) localTransaction.addModification(command);
return rv;
}