spring源码解析(一)

67 阅读1分钟

1)prepareRefresh();

      /**
       * 前戏,做容器刷新前的准备工作
       * 1、设置容器的启动时间
       * 2、设置活跃状态为true
       * 3、设置关闭状态为false
       * 4、获取Environment对象,并加载当前系统的属性值到Environment对象中
       * 5、准备监听器和事件的集合对象,默认为空的集合
       */

      prepareRefresh();

2)obtainFreshBeanFactory();

       // 创建容器对象:DefaultListableBeanFactory
      // 加载xml配置文件的属性值到当前工厂中,最重要的就是☆☆☆☆BeanDefinition☆☆☆☆
      ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();

image.png

加载xml配置文件的属性值到当前工厂中,最重要的就是BeanDefinition

加载xml配置文件的属性值到当前工厂中,最重要的就是BeanDefinition

加载xml配置文件的属性值到当前工厂中,最重要的就是BeanDefinition

3)prepareBeanFactory();

      // beanFactory的准备工作,对各种属性进行填充
      prepareBeanFactory(beanFactory);