//to make sure that there is only one instance per target rather than caller
Object callingObject = ((CallerInvocation) invocation).getCallingObject();
if (callingObject == null) return invocation.invokeNext(); // called from static method
Advised advised = (Advised) callingObject;
InstanceAdvisor advisor = advised._getInstanceAdvisor();
Interceptor interceptor = (Interceptor) advisor.getPerInstanceJoinpointAspect(joinpoint, aspectDefinition);
return interceptor.invoke(invocation);
}
else
{
Object targetObject = invocation.getTargetObject();
if (targetObject == null) return invocation.invokeNext(); // static method call or static field call
Advised advised = (Advised) targetObject;
InstanceAdvisor advisor = advised._getInstanceAdvisor();
Interceptor interceptor = (Interceptor) advisor.getPerInstanceJoinpointAspect(joinpoint, aspectDefinition);
return interceptor.invoke(invocation);
}
}