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 attributes; public static void load() { attributes = new ConcurrentHashMap(); Properties prop = new Properties(); try { prop.load(BaicPropertiesUtil.class.getResourceAsStream("/baic.properties")); for(Map.Entry 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"); } }