You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
package com.fr.plugin.config; |
|
|
|
import com.fr.config.ConfigContext; |
|
import com.fr.config.DefaultConfiguration; |
|
import com.fr.config.holder.Conf; |
|
import com.fr.config.holder.factory.Holders; |
|
import com.fr.stable.StringUtils; |
|
|
|
//第一步类继承自DefaultConfiguration |
|
public class MyConfig extends DefaultConfiguration { |
|
private static MyConfig config = null; |
|
|
|
//第二步写一个单例访问器(相当于注册配置和初始化) |
|
public static MyConfig getInstance() { |
|
if (config == null) { |
|
config = ConfigContext.getConfigInstance(MyConfig.class); |
|
} |
|
return config; |
|
} |
|
|
|
//补充,可以通过重写这个父类实现来实现在数据库中配置的namespace |
|
@Override |
|
public String getNameSpace() { |
|
return "zzlMyConfig"; |
|
} |
|
|
|
//第三步 注册要写的配置 |
|
private Conf<Integer> minSource = Holders.simple(60); |
|
private Conf<Integer> maxSource = Holders.simple(100); |
|
|
|
//第四步生成对应配置的get和set,注意这里要手动将Conf<*> 直接改成 * |
|
// public void setApiUrl(Conf<String> apiUrl) { |
|
// this.apiUrl = apiUrl; |
|
// } |
|
|
|
|
|
|
|
public Integer getMinSource() { |
|
return minSource.get(); |
|
} |
|
|
|
public void setMinSource(Integer minSource) { |
|
this.minSource.set(minSource); |
|
} |
|
|
|
public Integer getMaxSource() { |
|
return maxSource.get(); |
|
} |
|
|
|
public void setMaxSource(Integer maxSource) { |
|
this.maxSource.set(maxSource); |
|
} |
|
}
|
|
|