List?chain?=?this.advised.getInterceptorsAndDynamicInterceptionAdvice(method,targetClass); ?
//如果沒有可以應用到此方法的通知(Interceptor),此直接反射調用?method.invoke(target,?args)??
if?(chain.isEmpty())?{??
retVal?=?AopUtils.invokeJoinpointUsingReflection(target,method,?args);??
}?else?{??
//創建MethodInvocation??
invocation?=?newReflectiveMethodInvocation(proxy,?target,?method,?args,?targetClass,?chain);??
retVal?=?invocation.proceed();??
} ?
//?Massage?return?value?if?necessary.??
if?(retVal?!=?null?&&?retVal?==?target?&&method.getReturnType().isInstance(proxy)??
&&!RawTargetAccess.class.isAssignableFrom(method.getDeclaringClass()))?{??
//?Special?case:?it?returned"this"?and?the?return?type?of?the?method??
//?is?type-compatible.?Notethat?we?can't?help?if?the?target?sets??
//?a?reference?to?itself?inanother?returned?object.??
retVal?=?proxy;??
}??
return?retVal;??
}?finally?{??
if?(target?!=?null?&&?!targetSource.isStatic())?{??
//?Must?have?come?fromTargetSource.??
targetSource.releaseTarget(target);??
}??
if?(setProxyContext)?{??
//?Restore?old?proxy.??
AopContext.setCurrentProxy(oldProxy);??
}??
}??
} ?
評論
查看更多