02xml场景的程序入口

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("application.xml");

该构造器里做了很多事情,下面仅大致列一下,防止头脑一时接受不了。

一、构造器内部调用3个方法:

1、super(parent);//this.resourcePatternResolver = getResourcePatternResolver();//得到资源模式解析器,一会靠它解析xml路径字符串变成Resource对象。
2、setConfigLocations(new String[] {"application.xml"});// 把带有占位符"${xxx}/application.xml"变成比如"/abc/application.xml"的形式
3、refresh();// 做了很多工作,主要1是把xml变成BeanDefinition对象,2是根据BeanDefinition对象实例化所有bean

二、refresh();方法

1、prepareRefresh();方法
2、obtainFreshBeanFactory()方法 ★★★★★ 把xml变成BeanDefinition对象
3、prepareBeanFactory(beanFactory);方法
4、postProcessBeanFactory(beanFactory);空方法
5、invokeBeanFactoryPostProcessors(beanFactory);方法
6、registerBeanPostProcessors(beanFactory);方法
7、initMessageSource();方法
8、initApplicationEventMulticaster();方法
9、onRefresh();空方法
10、registerListeners();方法
11、finishBeanFactoryInitialization(beanFactory);方法 ★★★★★ 根据BeanDefinition对象实例化所有bean
12、finishRefresh();方法

posted @   bplan2010  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
点击右上角即可分享
微信分享提示