40 lines
1.2 KiB
Java
40 lines
1.2 KiB
Java
package com.ample.esb.util;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.util.Map;
|
|
import java.util.Properties;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
public class BaicPropertiesUtil {
|
|
private static Map<String, String> attributes;
|
|
|
|
public static void load() {
|
|
attributes = new ConcurrentHashMap<String, String>();
|
|
Properties prop = new Properties();
|
|
try {
|
|
prop.load(BaicPropertiesUtil.class.getResourceAsStream("/baic.properties"));
|
|
for(Map.Entry<Object, Object> entry : prop.entrySet()) {
|
|
if(entry.getKey() == null || entry.getValue() == null) {
|
|
continue;
|
|
}
|
|
attributes.put(entry.getKey().toString(), entry.getValue().toString());
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static void destroy() {
|
|
if(attributes != null) attributes.clear();
|
|
}
|
|
|
|
public static String get(String propName) {
|
|
if(attributes == null) load();
|
|
if("true".equals(attributes.get("is_prd"))){
|
|
return attributes.get(propName);
|
|
}
|
|
return attributes.get(propName+"_test");
|
|
}
|
|
}
|