return monitoredMethodCall.call(pjp, (PassiveMethodMonitor) monitor);
}
private MonitorMethod getAnnotation(final ProceedingJoinPoint pjp) {
MethodSignature signature = (MethodSignature) pjp.getSignature();
MonitorMethod fromSignature = signature.getMethod().getAnnotation(MonitorMethod.class);
if (fromSignature != null) {
return fromSignature;
}
// right, couldn't find it on the method signature, but we might be looking at an implementation of an interface
// so now look at the target object/class
try {
Method m = pjp.getTarget().getClass().getDeclaredMethod(signature.getName(), signature.getParameterTypes());
return m.getAnnotation(MonitorMethod.class);
} catch (NoSuchMethodException e) {
// hmm, not sure we should ever see this
throw new IllegalStateException("Couldn't find method that was called on the object it was called on");
}