spring源码流程图
2021-10-17 19:30:29 1 举报
spring
作者其他创作
大纲/内容
new AnnotationConfigApplicationContext(AppConfig.class);
实例化ConfigurationClassPostProcessor后置处理器ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry()
postProcessBeanDefinitionRegistry(){ 获得当前的beandfination 标记为是full类型还是lite类型 获得配置类中的commonscan将扫描到的放入BeanDefinitionMap处理importselect类型放入BeanDefinitionMap}
invokeBeanFactoryPostProcessors
将我们传递进来的配置类注册进BeanFactory的BeanDefinitionMap
处理实现类型为BeanDefinitionRegistryPostProcessor、BeanFactoryPostProcessor接口的后置处理器
父类构造器 DefaultListableBeanFactory(); this(); register(annotatedClasses); refresh();
将后置处理器解析为BeanDefinitionConfigurationClassPostProcessorAutowiredAnnotationBeanPostProcessorRequiredAnnotationBeanPostProcessorCommonAnnotationBeanPostProcessorEventListenerMethodProcessor
//执行自定义的BeanFactoryProcessor和内置的BeanFactoryProcessor invokeBeanFactoryPostProcessors(beanFactory); // 注册BeanPostProcessor registerBeanPostProcessors(beanFactory); // Initialize message source for this context. initMessageSource(); // Initialize event multicaster for this context. initApplicationEventMulticaster(); // Initialize other special beans in specific context subclasses. // 空方法 onRefresh(); // Check for listener beans and register them. registerListeners(); // Instantiate all remaining (non-lazy-init) singletons. finishBeanFactoryInitialization(beanFactory); // Last step: publish corresponding event. finishRefresh();
收藏
0 条评论
下一页