自动配置原理调用流程
2021-11-19 14:46:15 2 举报
自动配置原理调用流程
作者其他创作
大纲/内容
processConfigurationClass
SPI获取EnableAutoConfiguration为key的所有实现类
1.创建AutoConfigurationGroup2.在configurationClasses缓存
selectImports();
AnnotationConfigServletWebServerApplicationContextspringBoot的上下文对象
register
ConfigurationClassPostProcessor
processGroupImports();
process
getAttributes(annotationMetadata);
ConfigurationClassParser.DeferredImportSelectorGroupingHandler
postProcessBeanDefinitionRegistry
getCandidateConfigurations
Iterable
grouop.process
ConfigurationClassParser.DeferredImportSelectorGrouping
processImports
先回执行下面的handle方法创建holder对象才可以完成process的调用
processConfigBeanDefinitions
parse
postProcessor.postProcessBeanDefinitionRegistry
getAutoConfigurationEntry
AutoConfigurationImportSelector.AutoConfigurationGroup
invokeBeanDefinitionRegistryPostProcessors
getImports
handle
循环调用processImports大多数会processConfigurationClass
缓存中取出来转成集合返回
通过SPI获取过滤器。再执行过滤操作
AutoConfigurationImportSelector
getImportGrougetImportGroup
filter
获取到AutoConfigurationGroup的class对象
缓存autoConfigurationEntries
包装成AutoConfigurationEntry
doProcessConfigurationClass
refresh
自动配置原理调用与解析
PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors
handle中做的事有点诡异。下面判断基本不会成立this.deferredImportSelectors == null所以呢也不会执行register会在后面process完成这里就是创建holder对象(DeferredImportSelectorHolder)然后缓存进去this.deferredImportSelectors.add(holder);
ConfigurationClassParser
ConfigurationClassParser.DeferredImportSelectorHandler
invokeBeanFactoryPostProcessors
0 条评论
下一页