- 浏览: 48088 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (64)
- codes (9)
- javascript (4)
- servicemix (2)
- maven (2)
- webservice (1)
- docker (1)
- spring (25)
- git (1)
- css (3)
- hadoop (1)
- osgi (2)
- data (3)
- java (6)
- develop (5)
- tomcat (2)
- jvm (1)
- exceptions (3)
- company (0)
- utils (0)
- poi (3)
- 2018 (0)
- notepad (0)
- jquery (1)
- subject (0)
- 行业背景 (0)
- 2019 (0)
- https://blog.csdn.net/u012364631/article/details/47682011 (0)
- idea (0)
最新评论
web.xml
org.springframework.web.context.ContextLoaderListener --- ServletContextListener
web.xml
spring-web/org.springframework.web.context/
ContextLoader.properties
XmlWebApplicationContext --- ApplicationContext
StandardServletEnvironment --- ConfigurableEnvironment environment
MutablePropertySources
ApplicationContextInitializer
DefaultListableBeanFactory --- DefaultListableBeanFactory beanFactory
implements BeanDefinitionRegistry
Map<String, BeanDefinition> beanDefinitionMap
设置BeanExpressionResolver StandardBeanExpressionResolver
添加PropertyEditorRegistrar ResourceEditorRegistrar
添加BeanPostProcessor
解析BeanFactoryPostProcessor并执行
messageSource
applicationEventMulticaster
themeSource
ApplicationListener
由beanDefinition创建instance
LifecycleProcessor DefaultLifecycleProcessor
Lifecycle
#spring源码接口系列-PropertyEditroRegistry的使用(BeanWrapperImpl的设计)
1.ioc注册及调用
1.1 注册
AbstractApplicationContext#refresh
beanFactory.addPropertyEditorRegistrar(new ResourceEditorRegistrar(this, getEnvironment()));
AbstractBeanFactory#propertyEditorRegistrars
1.2 调用
AbstractAutowireCapableBeanFactory#doCreateBean
AbstractAutowireCapableBeanFactory#createBeanInstance
AbstractAutowireCapableBeanFactory#instantiateBean
AbstractBeanFactory#initBeanWrapper
AbstractAutowireCapableBeanFactory#populateBean
AbstractAutowireCapableBeanFactory#applyPropertyValues
BeanWrapperImpl#convertForProperty
TypeConverterDelegate#convertIfNecessary
2.注解注册及调用
一直以为springmvc请求方法的自定义的类的属性设置也是通过PropertyEditorRegistry,走读代码发现其实通过转换器conversion实现的
但它们殊途同归,最终都会走到
BeanWrapperImpl#convertForProperty
TypeConverterDelegate#convertIfNecessary
#场景1-设计场景
https://www.cnblogs.com/bobzeng/articles/1877140.html
https://qq85609655.iteye.com/blog/1453816
ApplicationContext parent = loadParentContext(servletContext);
这个方法的用途主要是用来解决Spring共享环境的,即,如果我们有多个WAR包部署在同一个服务器上,而且这些WAR都共享某一套业务逻辑层。如何共享一套业务逻辑包配置而不要每个WAR都单独配置,这时我们就可能需要Spring的共享环境了。
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
org.springframework.web.context.ContextLoaderListener --- ServletContextListener
web.xml
<context-param> <param-name>contextClass</param-name> <param-value>...</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>...</param-value> </context-param> <context-param> <param-name>contextInitializerClasses</param-name> <param-value>...</param-value> </context-param>
spring-web/org.springframework.web.context/
ContextLoader.properties
XmlWebApplicationContext --- ApplicationContext
StandardServletEnvironment --- ConfigurableEnvironment environment
MutablePropertySources
ApplicationContextInitializer
DefaultListableBeanFactory --- DefaultListableBeanFactory beanFactory
implements BeanDefinitionRegistry
Map<String, BeanDefinition> beanDefinitionMap
设置BeanExpressionResolver StandardBeanExpressionResolver
添加PropertyEditorRegistrar ResourceEditorRegistrar
添加BeanPostProcessor
解析BeanFactoryPostProcessor并执行
messageSource
applicationEventMulticaster
themeSource
ApplicationListener
由beanDefinition创建instance
LifecycleProcessor DefaultLifecycleProcessor
Lifecycle
#spring源码接口系列-PropertyEditroRegistry的使用(BeanWrapperImpl的设计)
1.ioc注册及调用
1.1 注册
AbstractApplicationContext#refresh
beanFactory.addPropertyEditorRegistrar(new ResourceEditorRegistrar(this, getEnvironment()));
AbstractBeanFactory#propertyEditorRegistrars
1.2 调用
AbstractAutowireCapableBeanFactory#doCreateBean
AbstractAutowireCapableBeanFactory#createBeanInstance
AbstractAutowireCapableBeanFactory#instantiateBean
AbstractBeanFactory#initBeanWrapper
AbstractAutowireCapableBeanFactory#populateBean
AbstractAutowireCapableBeanFactory#applyPropertyValues
BeanWrapperImpl#convertForProperty
TypeConverterDelegate#convertIfNecessary
2.注解注册及调用
一直以为springmvc请求方法的自定义的类的属性设置也是通过PropertyEditorRegistry,走读代码发现其实通过转换器conversion实现的
但它们殊途同归,最终都会走到
BeanWrapperImpl#convertForProperty
TypeConverterDelegate#convertIfNecessary
#场景1-设计场景
https://www.cnblogs.com/bobzeng/articles/1877140.html
https://qq85609655.iteye.com/blog/1453816
ApplicationContext parent = loadParentContext(servletContext);
这个方法的用途主要是用来解决Spring共享环境的,即,如果我们有多个WAR包部署在同一个服务器上,而且这些WAR都共享某一套业务逻辑层。如何共享一套业务逻辑包配置而不要每个WAR都单独配置,这时我们就可能需要Spring的共享环境了。
发表评论
-
spring疑难解惑-循环依赖的解决
2020-06-17 23:27 485AbstractAutowireCapableBeanFact ... -
spring容器
2019-07-14 08:47 286private final ServletContainer ... -
spring容器
2019-07-13 23:35 0spring容器与springmvc容器 73 ... -
spring源码学习系列3.4-spring mvc原理-codes
2019-01-21 22:46 266本篇章从核心类角度解读springmvc的原理 web.xm ... -
spring源码学习系列4.2-spring aop原理-codes
2018-12-04 22:29 544jdk: Proxy InvocationHandler ... -
spring源码学习系列4.1-spring实现对ibatis的事务管理
2018-09-17 15:44 530事务由spring管理,可以理解为由spring管理数据库连接 ... -
spring源码学习系列4-3种常用的自动代理创建器
2018-09-02 15:48 5463种自动代理器是 AnnotationAwareAspectJ ... -
spring源码学习系列1.2-spring事务代理深入分析2
2018-05-27 19:46 421提示: BeanPostProcessor AopUtils ... -
spring源码学习系列2.5-ApplicationContext初始化-设计模式
2018-05-08 15:17 470ApplicationContext容器的初始化可以通过模板方 ... -
spring源码学习系列3.3-DispatcherServlet初始化-设计模式
2018-05-07 11:12 561springmvc的核心是DispatcherServlet ... -
封装spring-security
2018-01-23 19:33 494github地址: https://github.com/ne ... -
eclipse导入spring源码
2018-05-12 07:20 942spring在git上的项目时gradle管理jar包的,所以 ... -
spring源码学习系列3.2.3-异常页面拦截机制
2017-07-29 19:07 720前序:本文的意义在于了解 tomcat处理异常 请求访问 ... -
spring源码学习系列3.2.2-How to bind String to Date
2017-07-17 12:40 570springmvc开发中,经常需将界面日期数据(String) ... -
spring源码学习系列3.2.1-command对象的绑定
2017-05-28 12:00 926在<spring源码学习系列3.2-handlerAda ... -
spring源码学习系列3.2-handlerAdapter执行
2017-05-28 12:01 383DispatcherServlet#doDispatch中调用 ... -
spring源码学习系列3.1-handlerMapping初始化
2017-05-28 11:56 676SimpleUrlHandlerMapping的继承体系 or ... -
spring源码学习系列2.4-finishRefresh会做什么
2017-05-06 16:36 543spring容器初始化完成后,调用finishRresh 该 ... -
spring源码学习系列3-springmvc原理
2017-05-28 11:56 426问题: springmvc是如何控 ... -
spring源码学习系列2-容器初始化入口-refresh
2017-04-23 21:33 453context=XmlWebApplicationContex ...
相关推荐
Spring5 框架 ---- IOC容器 ---- 代码 Spring5 框架 ---- IOC容器 ---- 代码 Spring5 框架 ---- IOC容器 ---- 代码 Spring5 框架 ---- IOC容器 ---- 代码 Spring5 框架 ---- IOC容器 ---- 代码 Spring5 框架 ---- ...
Spring Ioc源码分析系列--@Autowired注解的实现原理.doc
Java-Spring-SpringIoC容器-SpringIoC的学习 SpringIoC容器的学习笔记 主要介绍了IoC容器工作原理以及如何配置IoC容器 通过标签和注解配置容器
Spring.net二----初探IOC容器.rar
Spring Ioc源码分析系列--自动注入循环依赖的处理.doc
spring-demo10-注解-IOC.zip
Spring框架系列(7) - Spring IOC实现原理详解之IOC初始化流程.doc
它是一个基于IOC和AOP的构架多层j2ee系统的框架,但它不强迫你必须在每一层中必须使用Spring,因为它模块化的很好,允许你根据自己的需要选择使用它的某一个模块;它实现了很优雅的MVC,对不同的数据访问技术提供了...
Spring源代码解析(二):ioc容器在Web容器中的启动 Spring源代码分析(三):Spring JDBC Spring源代码解析(四):Spring MVC Spring源代码解析(五):Spring AOP获取Proxy Spring源代码解析(六):Spring声明式事务处理...
Spring框架系列(6) - Spring IOC实现原理详解之IOC体系结构设计.doc
01-Spring源码手写篇-手写IOC.md
spring ioc指的是控制反转,IOC容器负责实例化、定位、配置应用程序中的对象及建立这些对象间的依赖。交由Spring容器统一进行管理,从而实现松耦合
本系统实现了spring的控制反转思想(IOC)
spring IoC, 使用配置文件方式配置Bean的实例化和依赖注入
spring入门学习-2、IOC、DI知识.pdf
Spring框架系列(8) - Spring IOC实现原理详解之Bean实例化(生命周期,循环依赖等).doc
Java开发学习(二)----IOC、DI入门案例.doc
可选:用测试覆盖服务如何使项目运行从GitHub克隆存储库: git clone git@github.com:ifqthenp/otus-spring-hw-01-ioc-xml.git 使用以下命令进入文件夹: cd otus-spring-hw-01-ioc-xml 使gradlew脚本可执行(如果...
B-spring-ioc-container-homework:IoC容器基础知识Spring课程
你可以使用IoC容器,任何 Web 框架在顶部(只是底层用Spring框架,比如ssh,中间那层 用了 Spring ),但你也可以只使用 Hibernate 集成代码或 JDBC 抽象层。 Spring 框架支持声 明式事务管理,通过RMI或Web服务远程...