spring bean初始化过程
来源:互联网 发布:电子签章软件 编辑:程序博客网 时间:2024/05/22 14:14
SpringBean 初始化过程ClassPathXmlApplication reflsh()//记录执行时间prepareRefresh();//主要是创建beanFactory(DefaultListableBeanFactory),同时加载配置文件.xml中的beanDefinition //通过String[] configLocations = getConfigLocations()获取资源路径,//加载beanDefinition(XmlBeanDefinitionReader.loadBeanDefinitions(configLocations)) ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();//准备beanFactory//设置默认的组件(classLoader)prepareBeanFactory(beanFactory);try {//提供给子类实现一些postProcess的注册,如AbstractRefreshableWebApplicationContext注册一些Servlet相关的 //postProcess,真对web进行生命周期管理的Scope,通过registerResolvableDependency()方法注册指定ServletRequest,//HttpSession,WebRequest对象的工厂方法 postProcessBeanFactory(beanFactory);// Invoke factory processors registered as beans in the context.//调用所有BeanFactoryProcessor的postProcessBeanFactory()方法 invokeBeanFactoryPostProcessors(beanFactory);// Register bean processors that intercept bean creation.//注册BeanPostProcessor(BeanPostProcessor作用是用于拦截Bean的创建)registerBeanPostProcessors(beanFactory);// Initialize message source for this context.//初始化消息Bean initMessageSource();// Initialize event multicaster for this context.//初始化上下文的事件传播组建,ApplicationEvent触发时由multicaster通知给ApplicationListener initApplicationEventMulticaster();// Initialize other special beans in specific context subclasses.//ApplicationContext初始化一些特殊的bean onRefresh();// Check for listener beans and register them.///注册事件监听器,事件监听Bean统一注册到multicaster里头,ApplicationEvent事件触发后会由multicaster广播 registerListeners();// Instantiate all remaining (non-lazy-init) singletons.//非延迟加载的单例Bean实例化 finishBeanFactoryInitialization(beanFactory);// Last step: publish corresponding event.finishRefresh();}catch (BeansException ex) {// Destroy already created singletons to avoid dangling resources.destroyBeans();// Reset 'active' flag.cancelRefresh(ex);// Propagate exception to caller.throw ex;}
阅读全文
0 0
- Spring Bean 初始化过程
- Spring Bean 初始化过程
- Spring Bean 初始化过程
- Spring Bean 初始化过程
- Spring Bean 初始化过程
- Spring Bean初始化过程
- Spring Bean初始化过程
- spring bean初始化过程
- spring中bean初始化过程
- spring中bean初始化过程
- spring中bean初始化过程
- Spring中Bean初始化过程
- Spring 初始化bean过程图解
- Spring中Bean的初始化过程
- 关于Spring 中初始化bean的过程
- spring中bean的初始化过程
- spring源码学习 - 注解bean的初始化过程
- spring笔记6 容器加载过程、bean初始化
- caffe中解析器solver中各参数的含义
- FLV学习(一)网上资源搜集
- SpringMVC学习之前期小结
- springcloud feign 讲解
- PDSOFT2.5中科辅龙_最新版_USB加密锁运行稳定版.rar
- spring bean初始化过程
- python3/tensorflow1.1
- 机器学习之scikit-learn初识
- vxworks启动WDB没起来这从硬盘起来的,从网络起来没有问题
- swift中闭包block的使用
- Django后台管理系列之四
- mysql索引总结----mysql 索引类型以及创建
- 909422229_Hibernate第一节环境配置
- Linux下特有的reboot()函数的简介