// transaction is in a valid state before moving on, and throwing an exception if not.
boolean txValid = TransactionTable.isValid(tx);
if (!txValid)
throw new IllegalStateException("Transaction " + tx + " is not in a valid state to be invoking cache operations on.");
GlobalTransaction gtx;
if (transactions.add(tx)) {
gtx = txTable.getCurrentTransaction(tx, true);
TransactionContext transactionContext;
if (ctx.getGlobalTransaction() == null) {
ctx.setGlobalTransaction(gtx);
transactionContext = txTable.getTransactionContext(gtx);
ctx.setTransactionContext(transactionContext);
} else {
transactionContext = ctx.getTransactionContext();
}
if (gtx.isRemote()) {
// should be no need to register a handler since this a remotely initiated globalTransaction
if (trace) log.trace("is a remotely initiated gtx so no need to register a tx for it");
} else {
if (trace) log.trace("Registering sync handler for tx {0} and gtx {1}", tx, gtx);