package org.jbpm.properties; import java.io.InputStream; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; import org.apache.log4j.Logger; public class JBpm4Properties { private static String fileName = "/properties/jbpm4.properties"; private static ResourceBundle _cfgResourceBundle = null; static { try { if (_cfgResourceBundle == null) { InputStream is = JBpm4Properties.class.getResourceAsStream(fileName); if (is != null) { _cfgResourceBundle = new PropertyResourceBundle(is); } } } catch (Exception ee) { ee.printStackTrace(); } } 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) { try { return _cfgResourceBundle.getString(key).trim(); } catch (Exception e) { e.printStackTrace(); }return ""; } private static String getStrPro(ResourceBundle _cfgResourceBundle, String key, String defaultVal) { try { return _cfgResourceBundle.getString(key).trim(); } catch (Exception e) { e.printStackTrace(); }return defaultVal; } private static int getIntPro(ResourceBundle _cfgResourceBundle, String key) { try { return Integer.valueOf(_cfgResourceBundle.getString(key).trim()).intValue(); } catch (Exception e) { } return -1; } private static int getIntPro(ResourceBundle _cfgResourceBundle, String key, int defaultVal) { try { return Integer.valueOf(_cfgResourceBundle.getString(key).trim()).intValue(); } catch (Exception e) { e.printStackTrace(); }return defaultVal; } }