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