码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2016-03-30 16:42:47      阅读:498      评论:0      收藏:0      [点我收藏+]

标签:初始化   spring   概述   

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概述

标签:初始化   spring   概述   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!