HttpServletBean 源码阅读
来源:互联网 发布:淘宝特步 编辑:程序博客网 时间:2024/06/06 17:26
public abstract class HttpServletBean extends HttpServlet implements EnvironmentCapable, EnvironmentAware
HttpServletBean
继承自HttpServlet
,实现了EnvironmentCapable, EnvironmentAware
接口。
成员变量
有两个类成员变量:
@Nullable private ConfigurableEnvironment environment; private final Set<String> requiredProperties = new HashSet<>(4);
ConfigurableEnvironment
public interface ConfigurableEnvironment extends Environment, ConfigurablePropertyResolver
Configuration
接口大多数(如果不是全部)由Environment
类型来实现。 该接口提供工具用以①设置活跃和默认的profiles
和②操纵底层property sources
。 允许客户端设置和验证所需的(required
)属性,通过超级接口ConfigurablePropertyResolver
自定义转换服务。
property sources
可能会被删除,重新排序或替换; 并且可以使用从getPropertySources()
返回的MutablePropertySources
实例添加其他属性来源。
当ApplicationContext
正在使用Environment
时,一定要在context
的org.springframework.context.support.AbstractApplicationContext#refresh()
被调用之前执行。 这可以确保所有property sources
在容器引导过程中都可用,包括由org.springframework.context.support.PropertySourcesPlaceholderConfigurer
。
类方法
setActiveProfiles
setActiveProfiles
由实现抽象类AbstractEnvironment
实现:
@Overridepublic void setActiveProfiles(String... profiles) { Assert.notNull(profiles, "Profile array must not be null"); synchronized (this.activeProfiles) { this.activeProfiles.clear(); for (String profile : profiles) { validateProfile(profile); this.activeProfiles.add(profile); } }}
其中:
rivate final Set<String> activeProfiles = new LinkedHashSet<>();
protected void validateProfile(String profile) { if (!StringUtils.hasText(profile)) { throw new IllegalArgumentException("Invalid profile [" + profile + "]: must contain text"); } if (profile.charAt(0) == '!') { throw new IllegalArgumentException("Invalid profile [" + profile + "]: must not begin with ! operator"); }}
@Overridepublic void addActiveProfile(String profile) { if (logger.isDebugEnabled()) { logger.debug("Activating profile '" + profile + "'"); } validateProfile(profile); doGetActiveProfiles(); synchronized (this.activeProfiles) { this.activeProfiles.add(profile); }}
- HttpServletBean 源码阅读
- HttpServletBean
- SpringMVC源码分析--容器初始化(三)HttpServletBean
- SpringMVC源码分析--容器初始化(三)HttpServletBean
- 02.SpringMVC 初始化 - HttpservletBean
- 阅读源码
- 阅读源码
- 阅读源码
- 源码阅读
- JUnit源码阅读 -- 阅读基础
- 源码阅读系列:为什么要阅读源码?
- 源码阅读系列:源码阅读方法
- 阅读贪吃蛇源码
- 阅读贪吃蛇源码
- 阅读贪吃蛇源码
- 阅读贪吃蛇源码
- 如何阅读Linux源码
- DotText源码阅读(0)
- 最大差值
- mybatis非接口开发helloworld--最基本单表crud包括获得插入返回id,#$注入的区别
- Hbase的使用
- 51相关知识积累
- SAS学习笔记(四)
- HttpServletBean 源码阅读
- method_软阈值算子(Soft Thresholding)
- 为什么Wi-Fi用的最多是1,6,11 信道
- 真实环境的OracleGoldenGate配置参数详解
- 贪心算法之喷水设置
- TELE(树形dp+背包)
- Unity基础,相机跟随
- Vue 脱坑记
- JavaScript 15 遍历