一. HttpServletBean
public abstract class HttpServletBean extends HttpServlet implements EnvironmentCapable, EnvironmentAware
可以看出它是一个抽象类,这里呢,先来看它实现的两个接口。
public interface EnvironmentCapable {
/**
* Return the {@link Environment} associated with this component.
*/
Environment getEnvironment();
}
其中的方法呢,是获取跟这个组件相关的Environment。我们再来看Environment这个接口。
public interface Environment extends PropertyResolver {
/**
* 返回这个环境明确激活的profiles集合
*/
String[] getActiveProfiles();
/**
* 当没有明确设置激活profiles时,返回默认激活的profiles集合
*/
String[] getDefaultProfiles();
/**
* 返回一个或者多个给定的profiles是否被激活,即便是没有明确的激活profiles。
* 或者一个或者多个给定的profiles被包含在默认的profiles里。
* 如果一个profile以!开头,那么这个方法会返回true
* 如果参数p1是激活的,而参数p2没有激活,那么也会返回true
*/
@Deprecated
boolean acceptsProfiles(String... profiles);
/**
* Return whether the {@linkplain #getActiveProfiles() active profiles}
* match the given {@link Profiles} predicate.
*/
boolean acceptsProfiles(Profiles profiles);
}
再来看PropertyResolver接口
public interface PropertyResolver {
/**
* 返回给定的key是否可以用于解决
*/
boolean containsProperty(String key);
/**
* 返回给定key的value
*/
@Nullable
String getProperty(String key);
/**
* 返回给定key的value,如果没有的话,返回默认值
*/
String getProperty(String key, String defaultValue);
/**
* 返回给定key的指定类型的value
*/
@Nullable
<T> T getProperty(String key, Class<T> targetType);
/**
* 返回给定key的指定类型的value,如果没有的话,返回默认值
*/
<T> T getProperty(String key, Class<T> targetType, T defaultValue);
/**
* 返回给定key的value,如果没有的话,就抛出异常
*/
String getRequiredProperty(String key) throws IllegalStateException;
/**
* 返回给定key的指定类型的value,如果没有的话,就抛出异常
*/
<T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException;
/**
* 解析给定文本的${...}的占位符,用对应的value替换它们。不能被解析的,并且没