sxd-spring启动
2022-09-23 16:16:49 23 举报
AI智能生成
sxd-spring启动
作者其他创作
大纲/内容
new ClassPathXmlApplicationContext
super(parent)
AbstractApplicationContext
#resourceLoader
#resourceLoader
AbstractApplicationContext
#parent 为空
#parent 为空
setConfigLocations ()
设置文件加载并加载bean定义
设置文件加载并加载bean定义
AbstractRefreshableConfigApplicationContext
#resolvePath()
#resolvePath()
getEnvironment()
new StandardEnvironment()
AbstractRefreshableConfigApplicationContext
#setconfiglocations()
#setconfiglocations()
AbstractRefreshableConfigApplicationContext
#configLocations
#configLocations
refresh()
prepareRefresh()
前戏
前戏
obtainFreshBeanFactory()
创建工厂并加载beanDefinition
创建工厂并加载beanDefinition
refreshBeanFactory()
hasBeanFactory()
destroyBeans()
closeBeanFactory()
beanFactory=createBeanFactory()
getInternalParentBeanFactory()
new DefaultListableBeanFactory(null)
beanFactory.setSerializationId(getId())
customizeBeanFactory(beanFactory)
loadBeanDefinitions(beanFactory)
适配器模式
适配器模式
AbstractXmlApplicationContext
#loadBeanDefinitions()
#loadBeanDefinitions()
new XmlBeanDefinitionReader
初始化读取器
初始化读取器
loadBeanDefinitions(beanDefinitionReader)
AbstractBeanDefinitionReader
#loadBeanDefinitions(java.lang.String...)
#loadBeanDefinitions(java.lang.String...)
XmlBeanDefinitionReader
#doLoadBeanDefinitions
#doLoadBeanDefinitions
doLoadDocument
读取xml为文档
读取xml为文档
registerBeanDefinitions
解析文档注册bean
解析文档注册bean
createReaderContext
getNamespaceHandlerResolver
createDefaultNamespaceHandlerResolver
parseDefaultElement()
parseBeanDefinitionElement
parseBeanDefinitionElement
decorateBeanDefinitionIfRequired
registerBeanDefinition()
实际调用DefaultListableBeanFactory的方法
实际调用DefaultListableBeanFactory的方法
fireComponentRegistered
GenericBeanDefinition
子主题
delegate.parseCustomElement(ele)
this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
getHandlerMappings
namespaceHandler.init();
NamespaceHandlerSupport#parse
findParserForElement
configureScanner
scanner.doScan
findCandidateComponents
scanCandidateComponents
getMetadataReaderFactory().getMetadataReader(resource)
isCandidateComponent
ScannedGenericBeanDefinition
registerBeanDefinition
注册后置处理组件 registerComponents
delegate.parseCustomElement(root)
AnnotationConfigWebApplicationContext
GroovyWebApplicationContext
XmlWebApplicationContext
this.beanFactory = beanFactory
getBeanFactory()
prepareBeanFactory(beanFactory)
工厂的预初始化操作
工厂的预初始化操作
setBeanClassLoader(getClassLoader())
setBeanExpressionResolver
addPropertyEditorRegistrar
addBeanPostProcessor
设置忽略接口
ignoreDependencyInterface
ignoreDependencyInterface
registerResolvableDependency
addBeanPostProcessor
registerSingleton
postProcessBeanFactory(beanFactory)
扩展接口
扩展接口
invokeBeanFactoryPostProcessors(beanFactory)
调用bean的后置处理方法,在bean实例化之前
调用bean的后置处理方法,在bean实例化之前
invokeBeanFactoryPostProcessors()
beanFactory.getBeanNamesForType(BeanDefinitionRegistryPostProcessor.class
ConfigurationClassPostProcessor
processConfigBeanDefinitions
parse
parse
processConfigurationClass()
doProcessConfigurationClass
processMemberClasses
processPropertySource
addPropertySource
Process@ComponentScan
componentScanParser.parse
scanner.doScan
ConfigurationClassUtils
parse
processImports
getImports
processImports
ImportSelector
ImportBeanDefinitionRegistrar
other
process @ImportResource
process @Bean
retrieveBeanMethodMetadata
processInterfaces
Process superclass
deferredImportSelectorHandler.process
processGroupImports
grouping.getImports()
group.process
AutoConfigurationImportSelector
getCandidateConfigurations()
loadSpringFactories
loadFactoryNames
loadSpringFactories
getOrDefault
processImports
reader.loadBeanDefinitions
loadBeanDefinitionsForConfigurationClass
registerBeanDefinitionForImportedConfigurationClass
loadBeanDefinitionsForBeanMethod
loadBeanDefinitionsFromImportedResources
GroovyBeanDefinitionReader
XmlBeanDefinitionReader
reader.loadBeanDefinitions
loadBeanDefinitionsFromRegistrars
registerBeanPostProcessors(beanFactory);
注册bean创建的拦截处理器
注册bean创建的拦截处理器
registerBeanPostProcessors()
initMessageSource()
初始化消息源
初始化消息源
initApplicationEventMulticaster()
初始化事件
初始化事件
onRefresh()
其他特殊bean
其他特殊bean
registerListeners()
注册侦听器
注册侦听器
finishBeanFactoryInitialization(beanFactory)
实例化所有剩余的(非惰性初始化)单例
实例化所有剩余的(非惰性初始化)单例
setConversionService
addEmbeddedValueResolver
beanFactory.getBeanNamesForType(LoadTimeWeaverAware
beanFactory.setTempClassLoader
beanFactory.freezeConfiguration
beanFactory.preInstantiateSingletons
preInstantiateSingletons
for1
isFactoryBean
getBean(FACTORY_BEAN_PREFIX + beanName)
alreadyCreated.add(beanName)
mbd.isPrototype()
else
getBean(beanName)
for2
finishRefresh()
发布相应的事件
发布相应的事件
ApplicationContext.getBean()
AbstractBeanFactory#getBean(String name)
AbstractBeanFactory.doGetBean
doGetBean()
transformedBeanName(name)
getSingleton
parentBeanFactory
markBeanAsCreated
getMergedLocalBeanDefinition
dependsOn
AbstractAutowireCapableBeanFactory#createBean
resolveBeanClass(mbd, beanName);
doResolveBeanClass
evaluateBeanDefinitionString
ClassUtils.forName
mbd.resolveBeanClass
ClassUtils.forName(className, classLoader);
mbdToUse.prepareMethodOverrides();
resolveBeforeInstantiation
doCreateBean
mbd.isSingleton
createBeanInstance
resolveBeanClass
doResolveBeanClass
evaluateBeanDefinitionString
ClassUtils.forName
mbd.resolveBeanClass
ClassUtils.forName(className, classLoader);
instanceSupplier
mbd.getInstanceSupplier();
obtainFromSupplier
instantiateUsingFactoryMethod
mbd.getFactoryMethodName
instantiateUsingFactoryMethod
autowireConstructor
autowireConstructor
determineConstructorsFromBeanPostProcessors
instantiateBean
SimpleInstantiationStrategy#instantiate
BeanUtils.instantiateClass
instantiateWithMethodInjection
CglibSubclassingInstantiationStrategy#instantiate
子主题
new BeanWrapperImpl(beanInstance)
initBeanWrapper(bw);
instanceWrapper.getWrappedInstance()
instanceWrapper.getWrappedClass()
applyMergedBeanDefinitionPostProcessors
JmsListenerAnnotationBeanPostProcessor
ScheduledAnnotationBeanPostProcessor
RequiredAnnotationBeanPostProcessor
InitDestroyAnnotationBeanPostProcessor
CommonAnnotationBeanPostProcessor
super.postProcessMergedBeanDefinition
findLifecycleMetadata
buildLifecycleMetadata
checkConfigMembers
beanDefinition.registerExternallyManagedInitMethod(methodIdentifier);
beanDefinition.registerExternallyManagedDestroyMethod(methodIdentifier);
findResourceMetadata
buildResourceMetadata
field.isAnnotationPresent(webServiceRefClass)
field.isAnnotationPresent(ejbClass)
field.isAnnotationPresent(Resource.class)
injectionMetadataCache.put
checkConfigMembers
beanDefinition.registerExternallyManagedConfigMember
AutowiredAnnotationBeanPostProcessor
findAutowiringMetadata
buildAutowiringMetadata
injectionMetadataCache.put
checkConfigMembers
ApplicationListenerDetector
PersistenceAnnotationBeanPostProcessor
addSingletonFactory
populateBean
populateBean
hasInstantiationAwareBeanPostProcessors
postProcessAfterInstantiation
autowireByName
unsatisfiedNonSimpleProperties
for -> propertyNames
containsBean(propertyName)
getBean
pvs.add(propertyName, bean);
registerDependentBean
autowireByType
unsatisfiedNonSimpleProperties
for -> propertyNames
containsBean(propertyName)
getBean
pvs.add(propertyName, bean);
registerDependentBean
hasInstantiationAwareBeanPostProcessors
mbd.getDependencyCheck
postProcessProperties
CommonAnnotationBeanPostProcessor
InjectionMetadata#inject
AutowiredAnnotationBeanPostProcessor
findAutowiringMetadata
InjectionMetadata#inject
AutowiredAnnotationBeanPostProcessor#inject
resolvedCachedArgument
resolveFieldValue
DefaultListableBeanFactory#resolveDependency
createOptionalDependency
DependencyObjectProvider
createDependencyProvider
doResolveDependency
descriptor.resolveShortcut
resolveMultipleBeans
findAutowiringMetadata
resolveCandidate
beanFactory.getBean
applyPropertyValues
initializeBean
invokeAwareMethods
applyBeanPostProcessorsBeforeInitialization
invokeInitMethods
applyBeanPostProcessorsAfterInitialization
getObjectForBeanInstance
BeanFactoryUtils.isFactoryDereference
getCachedObjectForFactoryBean
getObjectFromFactoryBean
getObjectFromFactoryBean
doGetObjectFromFactoryBean
MyFactoryBean.getObject
beforeSingletonCreation
afterSingletonCreation
postProcessObjectFromFactoryBean
singletonObjects
DefaultListableBeanFactory#getBean(Class<T>)
resolveBean
resolveNamedBean
getBeanNamesForType
doGetBeanNamesForType
getBean
getParentBeanFactory
0 条评论
下一页