private ReplicableCommand attachGlobalTransaction(InvocationContext ctx, Transaction tx, VisitableCommand command) throws Throwable { if (trace) { log.trace(" local transaction exists - registering global tx if not present for " + Thread.currentThread()); } if (trace) { GlobalTransaction tempGtx = txTable.get(tx); log.trace("Associated gtx in txTable is " + tempGtx); } // register a sync handler for this tx - only if the globalTransaction is not remotely initiated. GlobalTransaction gtx = registerTransaction(tx, ctx); if (gtx != null) { command = replaceGtx(command, gtx); } else { // get the current globalTransaction from the txTable. gtx = txTable.get(tx); } // make sure we attach this globalTransaction to the invocation context. ctx.setGlobalTransaction(gtx); return command; }
protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx, TransactionContext tCtx, InvocationContext ctx) { if (trace) { log.trace("Setting up transactional context."); log.trace("Setting tx as " + tx + " and gtx as " + gtx); } ctx.setTransaction(tx); ctx.setGlobalTransaction(gtx); if (tCtx == null) { if (gtx != null) { ctx.setTransactionContext(txTable.get(gtx)); } else if (tx == null) { // then nullify the transaction tCtx as well ctx.setTransactionContext(null); } } else { ctx.setTransactionContext(tCtx); } }
if (ctx.getGlobalTransaction() == null) ctx.setGlobalTransaction(gtx); transactionContext = txTable.get(gtx); ctx.setTransactionContext(transactionContext);
/** * Sets the state of the InvocationContext based on the template context passed in * * @param template template to copy from */ public void setState(InvocationContext template) { if (template == null) { throw new NullPointerException("Template InvocationContext passed in to InvocationContext.setState() passed in is null"); } this.setGlobalTransaction(template.getGlobalTransaction()); this.setLocalRollbackOnly(template.isLocalRollbackOnly()); this.setOptionOverrides(template.getOptionOverrides()); this.setOriginLocal(template.isOriginLocal()); this.setTransaction(template.getTransaction()); }