您现在的位置是:首页 >技术杂谈 >Spring aop如何寻找advisor网站首页技术杂谈
Spring aop如何寻找advisor
1.bean的生命周期第一步回去解析所有的advisor
2.第四个是我们之前开启的注解@EnableAspectJAutoProxy
3.org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator#postProcessBeforeInstantiation
4.org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator#isInfrastructureClass
false
5.
6.
7. org.springframework.aop.aspectj.annotation.BeanFactoryAspectJAdvisorsBuilder#buildAspectJAdvisors
判断当前bean上是否有@Aspect
8.org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory#getAdvisors
===================下面开始解析after===============
org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator#postProcessAfterInitialization
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator#findCandidateAdvisors
总结:首先执行bean的生命周期第一步,会去寻找所有的@Aspect的bean,然后遍历里面的所有方法,判断是否有5个advice,如果有的话把其加入到advisors中,最后的到的产物: