apzl_leasing/src/com/ample/esb/util/BaicPropertiesUtil.java
2023-09-26 11:27:36 +08:00

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");
}
}