package com.vci.common.resource; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.Properties; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; import com.vci.common.log.ServerWithLog4j; public class IceClientProperties { private static String fileName = "/properties/iceClient.properties"; private static String developerFileName = "properties/iceClient.properties"; private static ResourceBundle _cfgResourceBundle = null; private static Properties confProperties = null; static { try { if ( _cfgResourceBundle == null ) { InputStream is = CommonProperties.class.getResourceAsStream(fileName); if (is != null) { _cfgResourceBundle = new PropertyResourceBundle(is); } if (_cfgResourceBundle == null) { File file = new File(developerFileName); if (file.exists()) { FileInputStream confPropertiesStream = new FileInputStream(developerFileName); confProperties = new Properties(); confProperties.load(confPropertiesStream); } } } } catch(Exception ee) { ee.printStackTrace(); ServerWithLog4j.logger.info("初始化服务器配置文件出错,请检查文件后重新启动"); } } // public static String NameService() // { // return getStrPro(_cfgResourceBundle, "NameService"); // } public static String Endpoints() { return getStrPro(_cfgResourceBundle, "Endpoints"); } public static String getStringProperty(String strKey) { return getStrPro(_cfgResourceBundle,strKey); } private static String getStrPro(ResourceBundle _cfgResourceBundle, String key){ String rs = null; try{ if (_cfgResourceBundle != null) { rs = _cfgResourceBundle.getString(key).trim(); } else if (confProperties != null){ rs = confProperties.getProperty(key); } }catch(Exception e){ rs = ""; } finally { if (rs == null) { rs = ""; } } return rs; } }