protected static String getEnvProperty(String key, Map<String, Object> hostEnv, Properties sysprops, boolean addToSystemProperties) { String v = (String) hostEnv.get(key); if (v == null) { v = System.getProperty(key); } if (v != null) { v = StringUtils.expandVars(v, sysprops); if (addToSystemProperties) { sysprops.setProperty(key, v); } } return v; }
protected String loadParametrizedFile(File file, Map<String, String> params) throws IOException { String content = FileUtils.readFileToString(file, UTF_8); // replace variables. return StringUtils.expandVars(content, createContextMap(params)); }
@Override protected String getContentToCopy(File fileToCopy, Map<String, String> prefs) throws PackageException { try { String content = FileUtils.readFileToString(fileToCopy, UTF_8); return StringUtils.expandVars(content, prefs); } catch (IOException e) { throw new PackageException("Failed to run parameterized copy for: " + fileToCopy.getName(), e); } }
protected static void loadSystemProperties() { File file = new File(home, "system.properties"); if (!file.isFile()) { return; } FileInputStream in = null; try { in = new FileInputStream(file); Properties p = new Properties(); p.load(in); for (Map.Entry<Object, Object> entry : p.entrySet()) { String v = (String) entry.getValue(); v = StringUtils.expandVars(v, System.getProperties()); System.setProperty((String) entry.getKey(), v); } } catch (IOException e) { throw new RuntimeException("Failed to load system properties", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { log.error(e); } } } }