/** * Load the InputStream returning the property map. * * @param p an existing property map to load into. * @param in the InputStream of the properties file to load. */ public static PropertyMap load(PropertyMap p, InputStream in) { Properties props = new Properties(); try { props.load(in); in.close(); return load(p, props); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Construct with a prefix, serverName and properties. */ public PropertiesWrapper(String prefix, String serverName, Properties properties) { this.serverName = serverName; this.prefix = prefix; this.propertyMap = PropertyMapLoader.load(null, properties); this.properties = propertyMap.asProperties(); }
/** * Load the file returning the property map. * @param p an existing property map to load into. * @param fileName the name of the properties file to load. */ public static PropertyMap load(PropertyMap p, String fileName){ InputStream is = findInputStream(fileName); if (is == null){ logger.severe(fileName+" not found"); return p; } else { return load(p, is); } }
/** * Load the ebean.properties (and test-ebean.properties if present). */ public static PropertyMap loadGlobalProperties() { boolean loadTestProperties = false; String fileName = System.getenv("EBEAN_PROPS_FILE"); if (fileName == null) { fileName = System.getProperty("ebean.props.file"); if (fileName == null) { loadTestProperties = PropertyMap.loadTestProperties(); fileName = "ebean.properties"; } } PropertyMap map = load(null, fileName); if (loadTestProperties) { // load test properties if present in classpath map = load(map, "test-ebean.properties"); } return map; }
/** * Load the file returning the property map. * * @param p an existing property map to load into. * @param fileName the name of the properties file to load. */ public static PropertyMap load(PropertyMap p, String fileName) { InputStream is = findInputStream(fileName); if (is == null) { return p; } else { return load(p, is); } }
/** * Load the file returning the property map. * * @param p * an existing property map to load into. * @param fileName * the name of the properties file to load. */ public static PropertyMap load(PropertyMap p, String fileName) { InputStream is = findInputStream(fileName); if (is == null) { logger.severe(fileName + " not found"); return p; } else { return load(p, is); } }
/** * Load the <code>test-ebean.properties</code>. */ public static PropertyMap loadTestProperties() { if (!PropertyMap.loadTestProperties()) { return new PropertyMap(); } return load(null, "test-ebean.properties"); }
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); } } }
globalMap = PropertyMapLoader.load(null, fileName); if (globalMap == null){
if (is != null) { logger.fine("loading properties from " + otherProps); load(p, is); } else { logger.severe("load.properties " + otherProps + " not found.");
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; }
if (is != null){ logger.fine("loading properties from "+otherProps); load(p, is); } else { logger.severe("load.properties "+otherProps+" not found.");