package com.vci.client.workflow.commom;
|
|
import com.vci.client.common.ClientLog4j;
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.io.InputStream;
|
//import java.util.ListResourceBundle;
|
import java.util.Properties;
|
import java.util.PropertyResourceBundle;
|
import java.util.ResourceBundle;
|
//import org.apache.log4j.Logger;
|
|
public class EventProperties {
|
private static String developerFileName = "properties/eventConf.properties";
|
private static ResourceBundle _cfgResourceBundle = null;
|
|
private static Properties confProperties = null;
|
|
//private static String tempKey = "workflow.event.type.trainsition";
|
|
static {
|
|
File file = new File(developerFileName);
|
|
try {
|
//if (_cfgResourceBundle == null) {
|
if (file.exists()) { //不需要打jar包的properties文件对应value值的收集
|
FileInputStream confPropertiesStream = new FileInputStream(developerFileName);
|
confProperties = new Properties();
|
confProperties.load(confPropertiesStream);
|
}else{
|
//modify by weidy@2020-12-18
|
//file存在只能是在服务器上直接使用bat启动的时候,在web start和调试的时候,这个获取不到值
|
InputStream is = EventProperties.class.getResourceAsStream("/" + developerFileName);
|
_cfgResourceBundle = new PropertyResourceBundle(is);
|
}
|
//}
|
} catch (Exception ee) {
|
ClientLog4j.logger.info("初始化服务器配置文件出错,请检查文件后重新启动",ee);
|
}
|
}
|
|
|
public static String getStringProperty(String strKey) {
|
return getStrPro(_cfgResourceBundle, strKey);
|
}
|
|
public static String getStringProperty(String strKey, String defaultVal) {
|
return getStrPro(_cfgResourceBundle, strKey, defaultVal);
|
}
|
|
public static int getIntProperty(String strKey) {
|
return getIntPro(_cfgResourceBundle, strKey);
|
}
|
|
public static int getIntProperty(String strKey, int defaultVal) {
|
return getIntPro(_cfgResourceBundle, strKey, defaultVal);
|
}
|
|
private static String getStrPro(ResourceBundle _cfgResourceBundle, String key) {
|
return getStrPro(_cfgResourceBundle, key, "");
|
}
|
|
private static String getStrPro(ResourceBundle _cfgResourceBundle, String key, String defaultVal) {
|
String rs = null;
|
try {
|
if (_cfgResourceBundle != null) {
|
rs = _cfgResourceBundle.getString(key).trim();
|
}
|
else if (confProperties != null)
|
rs = confProperties.getProperty(key);
|
else{
|
rs = defaultVal;
|
}
|
} catch (Exception e) {
|
rs = defaultVal;
|
} finally {
|
if (rs == null) {
|
rs = defaultVal;
|
}
|
}
|
return rs;
|
}
|
|
private static int getIntPro(ResourceBundle _cfgResourceBundle, String key) {
|
try {
|
return Integer.valueOf(getStrPro(_cfgResourceBundle, key)).intValue();
|
} catch (Exception e) {
|
}
|
return -1;
|
}
|
|
private static int getIntPro(ResourceBundle _cfgResourceBundle, String key,
|
int defaultVal) {
|
try {
|
return Integer.valueOf(getStrPro(_cfgResourceBundle, key,
|
String.valueOf(defaultVal))).intValue();
|
} catch (Exception e) {
|
}
|
return defaultVal;
|
}
|
}
|