/** * Format a header for display by a commandline tool at startup. * * @param cmd * the name of the command or class with <code>main(...)</code> * @param version * the full version name, e.g., <code>2.0B101</code> * @param date * the build date * * {0} - FiveSight ODE v{1} ({2})\nCopyright (c) 2003-2005 FiveSight * Technologies, Inc. */ public String msgCliHeader(String cmd, String version, String date) { return this.format("{0} - Apache ODE v{1} ({2})" + SystemUtils.lineSeparator() + "Copyright (c) 2006-2007 Apache ODE.", cmd, version, date); }
/** * Replace system property values in the given String using the ${system.property} convention. * * e.g., "The java version is ${java.version}" ==> "The java version is 1.5.0_11" */ public static String replaceSystemProperties(String str) { return replaceProperties(str, PROPERTY_PATTERN, System.getProperties()); }
public void load() throws IOException { if (_cfgFile.exists()) { __log.debug("config file exists: " + _cfgFile); FileInputStream fis = null; try { fis = new FileInputStream(_cfgFile); _props.load(fis); } finally { if (fis != null) { try { fis.close(); } catch (Exception ex) { ex.printStackTrace(); } } } } else { __log.debug("config file does not exists: " + _cfgFile); throw new FileNotFoundException("" + _cfgFile); } for (Object key : _props.keySet()) { String value = (String) _props.get(key); value = SystemUtils.replaceSystemProperties(value); _props.put(key, value); } }
String tmpDirPath = null; try { tmpDirPath = SystemUtils.javaTemporaryDirectory();
_outputDir = new File(SystemUtils.userDirectory());
private void replacePlaceholders() { Pattern systemProperty = Pattern.compile("\\$\\{system\\.([^\\}]+)\\}"); Pattern environmentVariable = Pattern.compile("\\$\\{env\\.([^\\}]+)\\}"); Pattern localPlaceholder = Pattern.compile("\\$\\{([^\\}]+)\\}"); for (Iterator it = hierarchicalMap.values().iterator(); it.hasNext();) { Map properties = ((ChainedMap) it.next()).child; for (Iterator it1 = properties.entrySet().iterator(); it1.hasNext();) { Map.Entry e = (Map.Entry) it1.next(); // /!\ replacement values themselves might contain placeholders. So always retrieve the value from the map entry e.setValue(SystemUtils.replaceProperties((String) e.getValue(), localPlaceholder, getRootMap().child)); e.setValue(SystemUtils.replaceProperties((String) e.getValue(), systemProperty, System.getProperties())); e.setValue(SystemUtils.replaceProperties((String) e.getValue(), environmentVariable, System.getenv())); } } }