level 13
当注解标记到类上面,Aspect使用@annotation去拦截时,会失效
2021年02月09日 02点02分
3
level 13
我的第一反应:wtf?
不可能吧,事务没用过吗?写到类上不说常见,但是一定见过吧
2021年02月09日 02点02分
5
level 13
我们都知道 spring给我们预留了两个炒鸡强大的扩展点:
BeanPostProcessor和BeanFactoryPostProcessor,咱们就来说说我们我们的重头戏InfrastructureAdvisorAutoProxyCreator
2021年02月09日 02点02分
7
level 13
InfrastructureAdvisorAutoProxyCreator实现了BeanPostProcessor.postProcessAfterInitialization,我们看看他到底做了什么
2021年02月09日 02点02分
9
level 13
也是一路小跑,发现这个类最终走到了org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator#findEligibleAdvisors方法,
List<Advisor> candidateAdvisors = findCandidateAdvisors();
List<Advisor> eligibleAdvisors = findAdvisorsThatCanApply(candidateAdvisors, beanClass, beanName);
第一条简单来说就是查询我们所有的aop拦截链,第二条就是规则匹配,这里的eligibleAdvisors,也就是我们最终需要的结果了
2021年02月09日 02点02分
12
level 13
@Pointcut("@annotation(com.boot.aspect.Log)")这种拦截时,if里面走到了introductionAwareMethodMatcher.matches(method, targetClass, hasIntroductions) 方法
2021年02月09日 02点02分
15