//檢查當(dāng)前advisor的pointcut是否可以匹配當(dāng)前方法??
MethodMatcher?mm?=pointcutAdvisor.getPointcut().getMethodMatcher(); ?
if?(MethodMatchers.matches(mm,method,?targetClass,?hasIntroductions))?{??
if(mm.isRuntime())?{??
//?Creating?a?newobject?instance?in?the?getInterceptors()?method??
//?isn't?a?problemas?we?normally?cache?created?chains.??
for?(intj?=?0;?j?
interceptorList.add(new?InterceptorAndDynamicMethodMatcher(interceptors[j],mm));??
}??
}?else?{??
interceptorList.addAll(Arrays.asList(interceptors));??
}??
}??
}??
}?else?if?(advisor?instanceof?IntroductionAdvisor){??
IntroductionAdvisor?ia?=(IntroductionAdvisor)?advisor;??
if(config.isPreFiltered()?||?ia.getClassFilter().matches(targetClass))?{??
Interceptor[]?interceptors=?registry.getInterceptors(advisor);??
interceptorList.addAll(Arrays.asList(interceptors));??
}??
}?else?{??
Interceptor[]?interceptors?=registry.getInterceptors(advisor);??
interceptorList.addAll(Arrays.asList(interceptors));??
}??
}??
return?interceptorList;??
} ?
這個(gè)方法執(zhí)行完成后,Advised中配置能夠應(yīng)用到連接點(diǎn)或者目標(biāo)類的Advisor全部被轉(zhuǎn)化成了MethodInterceptor.
接下來我們?cè)倏聪碌玫降臄r截器鏈?zhǔn)窃趺雌鹱饔玫摹?/p>
if?(chain.isEmpty())?{??
retVal?=?AopUtils.invokeJoinpointUsingReflection(target,method,?args);??
}?else?{??
//創(chuàng)建MethodInvocation??
invocation?=?newReflectiveMethodInvocation(proxy,?target,?method,?args,?targetClass,?chain);??
retVal?=?invocation.proceed();??
} ?
評(píng)論
查看更多