public static AppContextHolder performServerCall(Anchorable wrappedObject, String methodName, Method invokedMethod, Object[] args, Map<String, Object>appContext) throws Throwable {
_log.debug("Invoking: " + methodName);
String txnId = (String)appContext.get(TXN_ID);
AppContextHolder response;
if (txnId != null) {
appContext.remove(TXN_ID);
// We need to see if there's a transaction id, and if there is then get the thread that owns this id and then set up the transaction data.
ManagedThread thread = getThreadForTxn(txnId);
// This is in a distributed transaction, we must use the other thread (which must be waiting)
thread.initialiseForCall(appContext, methodName, invokedMethod, args, wrappedObject, txnId);
thread.executeCall();
if (thread.exception != null) {
response = new AppContextHolder(new AttributedException(thread.exception, thread.wasAborted));
}
else {
response = thread.response;
}
response.setParameter(WAS_ABORTED, Boolean.valueOf(thread.wasAborted));
}
else {
FrameworkUtils.setAppContextValues(appContext);
Object result = invokedMethod.invoke(wrappedObject, args);
response = new AppContextHolder(result);
postProcessParameters(response, invokedMethod, args);
}
return response;
}