SpringDataSource
2021-12-11 15:42:47 0 举报
AI智能生成
Spring源码阅读流程,为你阅读spring源码提供参考
作者其他创作
大纲/内容
this()
实例化:DefaultListableBeanFactory
用来生产和获得Bean
AnnotatedBeanDefinitionReader()
ConfigurationClassPostProcessor()
ConfigurationClassPostProcessor扩展了好多接口
AutowiredAnnotationBeanPostProcessor()
CommonAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor
EventListenerMethodProcessor
DefaultEventListenerFactory
ClassPathBeanDefinitionScanner()
register()
registerBeanDefinition
refresh()
prepareRefresh()
obtainFreshBeanFactory()
prepareBeanFactory(beanFactory)
增加类加载器、设置bean表达式解析器、属性编辑器支持
ApplicationContextAwareProcessor
忽略自动装配
自动装配加赋值
ApplicationListenerDetector
postProcessBeanFactory(beanFactory)
invokeBeanFactoryPostProcessors(beanFactory)
定义Set集合processedBeans存放处理器
定义两个List存放bean定义
获取实现PriorityOrdered接口的处理器。并体现热插拔思想
internalConfigurationAnnotationProcessor
获取实现Ordered接口的处理器
获取没有实现接口的处理器
顺序处理实现priorityOrdered、Ordered、没有实现接口的处理器
processConfigBeanDefinitions
通过parse()方法循环解析
doProcessConfigurationClass()
递归处理内部类
processMemberClasses()
处理@PropertySource注解
processPropertySource()
获得ComponentScan注解具体的内容
this.componentScanParser.parse()
doScan()循环包路径集合
findCandidateComponents()
scanCandidateComponents()
处理@Import注解
getImports()
processImports()
处理@Bean的方法
registerBeanPostProcessors(beanFactory)
PostProcessorRegistrationDelegate.registerBeanPostProcessors()
BeanPostProcessorChecker()
initMessageSource()
initApplicationEventMulticaster()
onRefresh()
registerListeners()
finishBeanFactoryInitialization(beanFactory)
getBean()
Spring Bean的生命周期
doGetBean()
getSingleton()
getObjectForBeanInstance()
parentBeanFactory.getBean()
markBeanAsCreated()
getMergedLocalBeanDefinition()
checkMergedBeanDefinition()
registerDependentBean()
createBean()
确保此时的 bean 已经被解析
resolveBeforeInstantiation()
applyBeanPostProcessorsBeforeInstantiation()
applyBeanPostProcessorsAfterInitialization()
postProcessAfterInitialization()
AbstractAutoProxyCreator.postProcessAfterInitialization()
wrapIfNecessary()
doCreateBean()
createBeanInstance()
applyMergedBeanDefinitionPostProcessors()
earlySingletonExposure
populateBean()
initializeBean()
registerDisposableBeanIfNecessary()
invokeAwareMethods()
applyBeanPostProcessorsBeforeInitialization()
invokeInitMethods()
applyBeanPostProcessorsAfterInitialization()
beanFactory.freezeConfiguration()
beanFactory.preInstantiateSingletons()
finishRefresh()
clearResourceCaches()
initLifecycleProcessor()
getLifecycleProcessor().onRefresh()
publishEvent()
LiveBeansView.registerApplicationContext(this)
AOP分析
@EnableAspectJAutoProxy
@Import(AspectJAutoProxyRegistrar.class)
registerBeanDefinitions
registerAspectJAnnotationAutoProxyCreatorIfNecessary()
AnnotationAwareAspectJAutoProxyCreator
AbstractAutoProxyCreator
BeanPostProcessor
InstantiationAwareBeanPostProcessor
SmartInstantiationAwareBeanPostProcessor
beand的后置处理器9次调用
注册BeanPostProcessors
refresh()
registerBeanPostProcessors
AbstractBeanFactory.addBeanPostProcessor()
AnnotationAwareAspectAutoProxyCreator
解析切面(缓存通知)
createBean()
resolveBeforeInstantiation
postProcessAfterIniyialization
创建代理
doCreateBean
initializeBean
applyBeanPostProcessorsAfterInitialization
postProcessAfterInitialization
调用代理
JdkDynamicAopProxy
0 条评论
下一页
为你推荐
查看更多
抱歉,暂无相关内容