//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
InstanceAdvisor instanceAdvisor = null;
if (targetObject instanceof Advised)
{
Advised advised = (Advised) targetObject;
instanceAdvisor = advised._getInstanceAdvisor();
}
else
{
Advisor advisor = invocation.getAdvisor();
if (advisor == null)