Advertisement

Spring-全面自定义-属性源

阅读量:

PropertySource:一种以名称/值形式进行属性存储的资源类型

复制代码
    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);//从资源中获取值
    
    
      
      
      
      
      
    

占位资源,其作用在于确保自身的排列顺序,随后可通过替换操作转换为实际资源,例如ServeltContext等:

复制代码
    public static class StubPropertySource extends PropertySource<Object> {
    		public StubPropertySource(String na

全部评论 (0)

还没有任何评论哟~