protected String resolvePath(String path) {
StringBuffer buf = new StringBuffer(path);
// The following code does not use JDK 1.4's StringBuffer.indexOf(String)
// method to retain JDK 1.3 compatibility. The slight loss in performance
// is not really relevant, as this code will typically just run on startup.
int startIndex = path.indexOf(PLACEHOLDER_PREFIX);
while (startIndex != -1) {
int endIndex = buf.toString().indexOf(PLACEHOLDER_SUFFIX, startIndex + PLACEHOLDER_PREFIX.length());
if (endIndex != -1) {
String placeholder = buf.substring(startIndex + PLACEHOLDER_PREFIX.length(), endIndex);
String propVal = System.getProperty(placeholder);
if (propVal != null) {
buf.replace(startIndex, endIndex + PLACEHOLDER_SUFFIX.length(), propVal);
startIndex = buf.toString().indexOf(PLACEHOLDER_PREFIX, startIndex + propVal.length());
}
else {
logger.warn("Could not resolve placeholder '" + placeholder +
"' in resource path [" + path + "] as system property");
startIndex = buf.toString().indexOf(PLACEHOLDER_PREFIX, endIndex + PLACEHOLDER_SUFFIX.length());
}
}
else {
startIndex = -1;
}
}
return buf.toString();
}
Resolve the given path, replacing ${...} placeholders with
corresponding system property values if necessary. |