log.trace("("+cache.getLocalAddress()+") call on method [" + m + "]");
}
// bypass for buddy group org metod calls.
if (isBuddyGroupOrganisationMethod(m)) return super.invoke(m);
InvocationContext ctx = getInvocationContext();
final Transaction suspendedTransaction;
boolean scrubTxsOnExit = false;
final boolean resumeSuspended;
Option optionOverride = ctx.getOptionOverrides();
setTransactionInContext(ctx, txManager);
if (optionOverride!= null && optionOverride.isFailSilently() && ctx.getTransaction() != null)
{
// make sure we remove the tx and global tx from the transaction table, since we don't care about this transaction
// and will just suspend it. - JBCACHE-1246
GlobalTransaction gtx = txTable.remove(ctx.getTransaction());
if (gtx != null) txTable.remove(gtx);
suspendedTransaction = txManager.suspend();
// set the tx in the invocation context to null now! - JBCACHE-785
ctx.setTransaction(null);
ctx.setGlobalTransaction(null);
resumeSuspended = true;
} else {
suspendedTransaction = null;
resumeSuspended = false;
}
Object result = null;
try
{
// first of all deal with tx methods - these are only going to be
// prepare/commit/rollback called by a remote cache, since calling
// such methods on TreeCache directly would fail.
if (isTransactionLifecycleMethod(m))
{
// this is a prepare, commit, or rollback.
// start by setting transactional details into InvocationContext.
ctx.setGlobalTransaction( findGlobalTransaction(m.getArgs()) );
if (log.isDebugEnabled()) log.debug("Got gtx from method call " + ctx.getGlobalTransaction());
ctx.getGlobalTransaction().setRemote( isRemoteGlobalTx(ctx.getGlobalTransaction()) );
//replaceGtx(m, gtxFromMethodCall);
if (ctx.getGlobalTransaction().isRemote()) remoteTransactions.put(ctx.getGlobalTransaction(),NULL);
switch (m.getMethodId())
{
case MethodDeclarations.optimisticPrepareMethod_id:
case MethodDeclarations.prepareMethod_id:
if (ctx.getGlobalTransaction().isRemote())
{
result = handleRemotePrepare(m, ctx.getGlobalTransaction());
scrubTxsOnExit = true;
if (cache.getUseInterceptorMbeans()&& statsEnabled)
m_prepares++;
}
else
{
if(log.isTraceEnabled()) log.trace("received my own message (discarding it)");
result = null;
}
break;
case MethodDeclarations.commitMethod_id:
case MethodDeclarations.rollbackMethod_id:
if (ctx.getGlobalTransaction().isRemote())
{
result = handleRemoteCommitRollback(m, ctx.getGlobalTransaction());
scrubTxsOnExit = true;
}
else
{
if (log.isTraceEnabled()) log.trace("received my own message (discarding it)");
result = null;
}
break;
}
}
else
{
// non-transaction lifecycle method.
result = handleNonTxMethod(m);
}
}
catch (Exception e)
{
if (optionOverride == null || !optionOverride.isFailSilently()) throw e;
log.trace("There was a problem handling this request, but " +
"failSilently was set, so suppressing exception", e);
}
finally
{
if (resumeSuspended)
{
txManager.resume(suspendedTransaction);
}
else
{
if (ctx.getTransaction() != null && isValid(ctx.getTransaction()))
{
copyInvocationScopeOptionsToTxScope(ctx);
}
}