// 配置文件名
private static final String CONFIG_CONTEXT_FILE_NAME = "context-zzgjs.properties";
private static Configuration ins=null;
private static Log log=LogFactory.getLog(Configuration.class);
static {
Properties datas = new Properties();
try {
datas.load(Configuration.class.getClassLoader().getResourceAsStream(CONFIG_CONTEXT_FILE_NAME));
} catch (IOException e) {
throw new PafaRuntimeException("Could not load configure file in classpath: "
+ CONFIG_CONTEXT_FILE_NAME + "!", e);
}
ins=new Configuration(datas);
}
private Configuration(Properties configure){
super(configure);
}
/**
* 得到配置属性值
*
* @param key 属性名称
* @return 属性值
*/
public static String getValue(String key) {
String value=ins.getString(key);
if(value==null){
log.warn("Cofig item ["+key+"] is null");
}
return value;
}
/**
* 得到配置属性值
*
* @param key 属性名称
* @param defaultValue 默认值
* @return 属性值
*/
public static String getValue(String key, String defaultValue) {
return ins.getString(key,defaultValue);
}
public static Map getConfig(){
return ins.datas;
}
public static Configuration getInstance(){
return ins;
}
}