PropertySource:属性资源,以name/value形式存储
protected final String name; //属性名字
protected final T source; //属性资源
配合属性解析器使用的接口:
public boolean containsProperty(String name) {//判断该资源是否含有指定名称的key
return (getProperty(name) != null);
}
@Nullable
public abstract Object getProperty(String name);//从资源中获取值
占位资源,用于保证自己的顺序,后续通过replace换成真实资源,例如ServeltContext等:
public static class StubPropertySource extends PropertySource<Object> {
public StubPropertySource(String name) {
super(name, new Object());
}
@Override
@Nullable
public String getProperty(String name) {
return null;
}
}
在springframework核心包中有一个实现,可以枚举属性名字:
public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
public EnumerablePropertySource(String name, T source) {
super(name, source);
}
protected EnumerablePropertySource(String name) {
super(na