Spring生命周期
2020-12-09 16:54:07 0 举报
Spring生命周期
作者其他创作
大纲/内容
AbstractRefreshableConfigApplicationContextresolvePath
allowCircularReferences
createBeanFactory
结束
@Autowired
addEmbeddedValueResolver
importBeanDefinitionResourceimport
freezeConfiguration
PropertyPlaceholderHelperreplacePlaceholders
destroyBeans(); closeBeanFactory();
isLiteConfigurationCandidate
AbstractApplicationContextrefresh()
obtainFreshBeanFactory
Component.classComponentScan.classImport.classImportResource.classBean.class
AbstractBeanDefinitionParserparse()
PropertyPlaceholderBeanDefinitionParserdoParse
AbstractPropertyLoadingBeanDefinitionParserdoParse
prepareBeanFactory(beanFactory);
loadBeanDefinitions
ConfigurationClassParserparse
DefaultNamespaceHandlerResolver
AbstractSingleBeanDefinitionParserparseInternal
Component.class
ImportResource.class
postProcessBeanDefinitionRegistry
DisposableBeandestroy()
isFullConfigurationCandidate
setConversionService
resolveBeforeInstantiation
initBeanDefinitionReader
否
DefaultDocumentLoaderloadDocument
1
xml
Resource[] resourcesloadBeanDefinitions(resources)
parser.parse(candidates);
autowireByName/autowireByType
new ConfigurationClassParser
PropertySources.class
DefaultNamespaceHandlerResolverresolve
createDefaultNamespaceHandlerResolver
doGetObjectFromFactoryBean
autowireConstructor
prepareRefresh
postProcessBeanFactory
obtainFromSupplier
MergedBeanDefinitionPostProcessor
AbstractApplicationContextgetEnvironment
XmlBeanDefinitionReaderloadBeanDefinitions(new EncodedResource(resource))
AnnotationConfigUtilsregisterAnnotationConfigProcessors
createReaderContext(resource)
NamespaceHandlerSupportparse()
XmlWebApplicationContextloadBeanDefinitions
processConfigurationClass
doResolvePlaceholders
Configuration.class
自定义 destroy-method
instantiateUsingFactoryMethod
PropertyOverrideBeanDefinitionParserdoParse
Import.class
registerDisposableBeanIfNecessary
ComponentScanBeanDefinitionParserparse()
AbstractRefreshableApplicationContextsuper()
Bean.class
applyPropertyValues
BeanDefinitionDocumentReaderregisterBeanDefinitions
createPlaceholderHelper
applyBeanPostProcessorsAfterInitialization
getObjectForBeanInstance
getNamespaceHandlerResolver()
2
registerBeanPostProcessors
AbstractXmlApplicationContextsuper()
修改/添加
invokeAwareMethods
1、internalConfigurationAnnotationProcessor2、internalConfigurationBeanNameGenerator3、internalAutowiredAnnotationProcessor4、internalRequiredAnnotationProcessor5、internalCommonAnnotationProcessor6、internalPersistenceAnnotationProcessor7、PersistenceAnnotationBeanPostProcessor8、internalEventListenerProcessor9、internalEventListenerFactory
getBean
DestructionAwareBeanPostProcessorspostProcessBeforeDestruction()
String[] configLocationsloadBeanDefinitions(configLocation)
BeanDefinitionParserDelegateparseCustomElement
DefaultSingletonBeanRegistrygetSingleton
allowBeanDefinitionOverriding
ComponentScans.classComponentScan.class
beanInstance instanceof FactoryBean
AbstractAutowireCapableBeanFactorycreateBean
AbstractBeanFactorygetBean
new XmlBeanDefinitionReader(beanFactory)
AbstractRefreshableConfigApplicationContextsuper()
this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri)
processBeanDefinitionbean
AbstractApplicationContextthis()
其他 BeanPostProcessor
end
AbstractApplicationContext1、this.closed.set(false);2、this.active.set(true);3、initPropertySources();4、getEnvironment().validateRequiredProperties();5、earlyApplicationListeners6、applicationListeners7、earlyApplicationEvents
ClassPathXmlApplicationContextsuper(parent);
AbstractRefreshableApplicationContextrefreshBeanFactory
createBeanInstance
new ApplicationListenerDetector()
invokeBeanDefinitionRegistryPostProcessors
processAliasRegistrationalias
PostProcessorRegistrationDelegateregisterBeanPostProcessors
createBeanDefinitionDocumentReader
XmlReaderContext
doProcessConfigurationClass
AbstractPropertyResolverresolveRequiredPlaceholders
是
DefaultListableBeanFactorypreInstantiateSingletons
initializeBean
getResourcePatternResolver
applyBeanPostProcessorsBeforeInitialization
ClassPathXmlApplicationContext
invokeBeanFactoryPostProcessors
\"base-package\
loadBeanDefinitions(resource);
processConfigBeanDefinitions
GenericBeanDefinition
parseStringValue
FactoryBeanRegistrySupportgetObjectFromFactoryBean
ClassPathXmlApplicationContextsetConfigLocations
invokeInitMethods
doGetBean
1、setBeanClassLoaderspan style=\"font-size: inherit;\
preInstantiateSingletons
registerComponents
finishBeanFactoryInitialization
AbstractBeanDefinitionReaderloadBeanDefinitions
setEnvironment(getEnvironment());setResourceLoader(this);setEntityResolver(new ResourceEntityResolver(this));
BeanDefinitionRegistry
new BeanPostProcessorChecker()
DefaultBeanDefinitionDocumentReaderdoRegisterBeanDefinitions
doCreateBean
populateBean
doRegisterBeanDefinitions(ele);beans
BeanDefinitionRegistryPostProcessor
factory.getObject()
getBean(weaverAwareName)
singletonFactory.getObject()
BeanFactoryPostProcessor
3
ConfigurationClassPostProcessor1、postProcessBeanDefinitionRegistry2、postProcessBeanFactory
META-INF/spring.handlers
registerBeanDefinitions
PostProcessorRegistrationDelegateinvokeBeanFactoryPostProcessors
AbstractApplicationContextPathMatchingResourcePatternResolver
bean
doLoadBeanDefinitions
getHandlerMappings()
DefaultListableBeanFactory
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
InstantiationAwareBeanPostProcessors
instantiateBean
取出/处理
initMessageSourceinitApplicationEventMulticasteronRefreshregisterListeners
prepareMethodOverrides
customizeBeanFactory
ClassPathXmlApplicationContextrefresh
收藏
收藏
0 条评论
下一页