首页 > 编程语言 > 详细

一、   Spring启动时加载和初始化bean概述

时间:2016-03-30 16:41:26      阅读:400      评论:0      收藏:0      [点我收藏+]

Spring Context继承关系

ClassPathXmlApplicationContext->AbstractXmlApplicationContext->AbstractRefreshableConfigApplicationContext->AbstractRefreshableApplicationContext

->AbstractApplicationContext

而AbstractRefreshableApplicationContext 包含DefaultListableBeanFactory beanFactory

DefaultListableBeanFactory->AbstractAutowireCapableBeanFactory->AbstractBeanFactory->FactoryBeanRegistrySupport->DefaultSingletonBeanRegistry


AbstractBeanFactory有如下元素

final Map<String, RootBeanDefinition> mergedBeanDefinitions=new ConcurrentHashMap<String, RootBeanDefinition>(64);

final List<BeanPostProcessor> beanPostProcessors = new ArrayList<BeanPostProcessor>();

boolean hasInstantiationAwareBeanPostProcessors;



1)[ClassPathXmlApplicationContext] ClassPathXmlApplicationContext(String configLocation)

this(new String[] {configLocation}, true, null);


2)[ClassPathXmlApplicationContext] ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, ApplicationContext parent)

if (refresh) { refresh(); }


3)[AbstractApplicationContext]  refresh()

ConfigurableListableBeanFactory beanFactory=obtainFreshBeanFactory();//解析Xml组装eanDefinition

...

invokeBeanFactoryPostProcessors(beanFactory);

registerBeanPostProcessors(beanFactory);//注册BeanPostProcessors.

...

finishBeanFactoryInitialization(beanFactory);//根据BeanDefinition初始化Bean


一、   Spring启动时加载和初始化bean概述

原文:http://2828408.blog.51cto.com/2818408/1758326

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!