spring 相关

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

2019-01-08  本文已影响0人  aix91

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. 执行业务方法

上一篇下一篇

猜你喜欢

热点阅读