/** * Load the <code>test-ebean.properties</code>. */ public static PropertyMap loadTestProperties() { if (!PropertyMap.loadTestProperties()) { return new PropertyMap(); } return load(null, "test-ebean.properties"); }
/** * Go through all the properties and evaluate any expressions that have not * been resolved. */ public void evaluateProperties() { for (Entry<String, String> e : entrySet()) { String key = e.getKey(); String val = e.getValue(); String eval = eval(val); if (eval != null && !eval.equals(val)) { put(key, eval); } } }
public synchronized int getInt(String key, int defaultValue) { String value = get(key); if (value == null) { return defaultValue; } else { return Integer.parseInt(value); } }
public static PropertyMap load(PropertyMap p, Properties props) { if (p == null) { p = new PropertyMap(); } // put values in initially without any evaluation for (Map.Entry<Object, Object> entry : props.entrySet()) { String key = ((String) entry.getKey()).toLowerCase(); String val = ((String) entry.getValue()); if (val != null) { val = val.trim(); } p.put(key, val); } p.evaluateProperties(); String otherProps = p.remove("load.properties"); if (otherProps == null) { otherProps = p.remove("load.properties.override"); } if (otherProps != null) { otherProps = otherProps.replace("\\", "/"); InputStream is = findInputStream(otherProps); if (is != null) { logger.debug("loading properties from " + otherProps); load(p, is); } else { logger.error("load.properties " + otherProps + " not found."); } } return p; }
private static void initPropertyMap() { String fileName = System.getenv("EBEAN_PROPS_FILE"); if (fileName == null) { fileName = System.getProperty("ebean.props.file"); if (fileName == null) { fileName = "ebean.properties"; } } globalMap = PropertyMapLoader.load(null, fileName); if (globalMap == null) { // ebean.properties file was not found... but that // is ok because we are likely doing programmatic config globalMap = new PropertyMap(); } String loaderCn = globalMap.get("ebean.properties.loader"); if (loaderCn != null) { // a Runnable that can be used to customise the initialisation // of the GlobalProperties try { Runnable r = (Runnable) ClassUtil.newInstance(loaderCn); r.run(); } catch (Exception e) { String m = "Error creating or running properties loader " + loaderCn; throw new RuntimeException(m, e); } } }
/** * Put all evaluating any expressions in the values. */ public synchronized void putEvalAll(Map<String, String> keyValueMap) { for (Map.Entry<String, String> entry : keyValueMap.entrySet()) { putEval(entry.getKey(), entry.getValue()); } }
/** * Parse and evaluate any expressions that have not already been evaluated. */ public static synchronized void evaluateExpressions() { getPropertyMap().evaluateProperties(); }
synchronized void putAll(Map<String, String> keyValueMap) { Iterator<Entry<String, String>> it = keyValueMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> entry = it.next(); put(entry.getKey(), entry.getValue()); } }
/** * Parse the string replacing any expressions like ${catalina.base}. * <p> * This will evaluate expressions using first environment variables, than java * system variables and lastly properties in ebean.properties - in that order. * </p> * <p> * Expressions start with "${" and end with "}". * </p> */ public static String evaluateExpressions(String val) { return getPropertyMap().eval(val); }
/** * Return as standard Properties. */ public Properties asProperties() { Properties properties = new Properties(); for (Entry<String, String> e : entrySet()) { properties.put(e.getKey(), e.getValue()); } return properties; }
/** * Return a boolean property with a default value. */ public static synchronized boolean getBoolean(String key, boolean defaultValue) { return getPropertyMap().getBoolean(key, defaultValue); }
/** * Return a int property with a default value. */ public static synchronized int getInt(String key, int defaultValue) { return getPropertyMap().getInt(key, defaultValue); }
p = new PropertyMap(); val = val.trim(); p.put(key, val); p.evaluateProperties(); String otherProps = p.remove("load.properties"); if (otherProps == null) { otherProps = p.remove("load.properties.override");
globalMap = new PropertyMap(); String loaderCn = globalMap.get("ebean.properties.loader"); if (loaderCn != null){
/** * Set a Map of key value properties. */ public static synchronized void putAll(Map<String, String> keyValueMap) { for (Entry<String, String> e : keyValueMap.entrySet()) { getPropertyMap().putEval(e.getKey(), e.getValue()); } }
/** * Parse and evaluate any expressions that have not already been evaluated. */ public static synchronized void evaluateExpressions() { getPropertyMap().evaluateProperties(); }
synchronized void putAll(Map<String, String> keyValueMap) { Iterator<Entry<String, String>> it = keyValueMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> entry = it.next(); put(entry.getKey(), entry.getValue()); } }
/** * Parse the string replacing any expressions like ${catalina.base}. * <p> * This will evaluate expressions using first environment variables, * than java system variables and lastly properties in ebean.properties * - in that order. * </p> * <p> * Expressions start with "${" and end with "}". * </p> */ public static String evaluateExpressions(String val) { return getPropertyMap().eval(val); }
/** * Return a boolean property with a default value. */ public static synchronized boolean getBoolean(String key, boolean defaultValue) { return getPropertyMap().getBoolean(key, defaultValue); }
/** * Return a int property with a default value. */ public static synchronized int getInt(String key, int defaultValue) { return getPropertyMap().getInt(key, defaultValue); }