Call call = new Call(method, args);
CallStack callStack = (CallStack)callStackHolder.get();
callStack.beginCall(call);
try {
interceptor.preInvoke(callStack);
} catch (Throwable t) {
_logger.log(Level.FINE, "core.interceptor_preinvoke_fail",
t.getMessage());
_logger.log(Level.FINEST,
"core.interceptor_preinvoke_exception", t);
}
Object result = null;
boolean success = true;
Throwable failReason = null;
try {
result = method.invoke(delegate, args);
} catch (InvocationTargetException ite) {
success = false;
failReason = ite.getTargetException();
throw failReason;
} catch (Throwable t) {
success = false;
failReason = t;
throw failReason;
} finally {
if (!success) {
call.setState(CallState.FAILED);
call.setFailureReason(failReason);
}
call.setResult(result);
if(!(call.getState().isFailed()))
call.setState(CallState.SUCCESS);
try {
interceptor.postInvoke(callStack);
} catch (Throwable t) {
_logger.log(Level.FINE, "core.interceptor_postinvoke_fail",
t.getMessage());
_logger.log(Level.FINEST,
"core.interceptor_postinvoke_exception", t);
}
callStack.endCall();
}
return result;