Lengxf_spring6源码解析
2023-06-09 17:08:38 0 举报
spring6源码解析
作者其他创作
大纲/内容
AnnotationConfigApplicationContext仅介绍注解形式的源码流程此类为加载的入口
this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader);源数据读取工厂
实际使用的条件评估器
this.reader.register(componentClasses);向注解读取器中注册初始类registerBean(componentClass);doRegisterBean()
new AnnotationScopeMetadataResolver()#resolveScopeMetadata()解析源数据信息
registerDefaultFilters()this.includeFilters.add注册默认过滤器
new AnnotationTypeFilter(ManagedBean.class)
this.reader = new AnnotatedBeanDefinitionReader(this)注册注解类读取器
new AnnotationTypeFilter(Named.class)
DefaultListableBeanFactory#setAutowireCandidateResolvernew ContextAnnotationAutowireCandidateResolver()设置上下文注解自动装配判断解析器
InitDestroyAnnotationBeanPostProcessor
DefaultListableBeanFactory#setDependencyComparatorAnnotationAwareOrderComparator.INSTANCE设置依赖比较器
EventListenerMethodProcessor
ConfigurationClassPostProcessor
AutowiredAnnotationBeanPostProcessor
this.conditionEvaluator.shouldSkip(abd.getMetadata())判断当前beandefinition是否需要跳过构建
register(componentClasses);注册初始扫描类
setResourceLoader(resourceLoader)注册资源管理器
实例化DefaultStartupStep存放启动器状态信息等默认启动器不存在价值意义
BeanDefinitionCustomizer#customize用户自定义bean定义处理
new AnnotationTypeFilter(Component.class)
this.registry = registry;把AnnotationConfigApplicationContext单做注册器
this();调用本方法无参构造器
refresh();刷新容器
AnnotationConfigUtils.applyScopedProxyMode判断代理模式
AnnotationConfigUtils.registerAnnotationConfigProcessors(this.registry)把AnnotationConfigApplicationContext注册为注解配置处理器
PersistenceAnnotationBeanPostProcessor
DefaultEventListenerFactory
条件判断然后注册默认的功能bean
AnnotationConfigUtils.processCommonDefinitionAnnotations(abd)处理注解;同时会判断Primary / Lazy 注解如果不是二者则包装为new AutowireCandidateQualifier(qualifier)
CommonAnnotationBeanPostProcessor
this.scanner = new ClassPathBeanDefinitionScanner(this)注册扫描器
setEnvironment(environment)注册环境变量
new StandardEnvironment()
DefaultApplicationStartup#start()开启默认的启动器
font color=\"#323232\
this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader)路径匹配解析器
this.componentsIndex = CandidateComponentsIndexLoader.loadIndex(this.resourcePatternResolver.getClassLoader());组件索引
收藏
收藏
0 条评论
下一页