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