美文网首页spring 相关
Spring注解--AOP原理(一):整体流程

Spring注解--AOP原理(一):整体流程

作者: aix91 | 来源:发表于2019-01-08 19:53 被阅读0次

1. 添加@EnableAspectJAutoProxy注解,开启AOP

2. 在容器中引入 AnnotationAwareAspectJAutoProxyCreator

@Import(AspectJAutoProxyRegistrar.class)
public @interface EnableAspectJAutoProxy {...}

public static BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry, Object source) {
        return registerOrEscalateApcAsRequired(AnnotationAwareAspectJAutoProxyCreator.class, registry, source);
    }

更多AnnotationAwareAspectJAutoProxyCreator的信息,请参考Spring注解--AOP原理(二):AnnotationAwareAspectJAutoProxyCreator

3. 容器的创建与初始化(AbstractApplicationContext)

@Override
public void refresh() throws BeansException, IllegalStateException {
...
//注册BeanPostProcessor
registerBeanPostProcessors(beanFactory);
...
//注册业务bean或者其代理对象
finishBeanFactoryInitialization(beanFactory);
}

4. 执行业务方法

相关文章

网友评论

    本文标题:Spring注解--AOP原理(一):整体流程

    本文链接:https://www.haomeiwen.com/subject/otavrqtx.html