Я сделал что-то подобное, и это не так сложно, вы просто создаете подкласс класса Properties и реализуете свой собственный метод getProperty , проверяете шаблон и заменяете его при необходимости.
//this makes the pattern ${sometext}
static public final String JAVA_CONFIG_VARIABLE = "\\$\\{(.*)\\}";
@Override
public String getProperty(String key)
{
String val = super.getProperty(key);
if( val != null && val.indexOf("${") != -1 )
{
//we have at least one replacable parm, let's replace it
val = replaceParms(val);
}
return val;
}
public final String replaceParms(String in)
{
if(in == null) return null;
//this could be precompiled as Pattern is supposed to be thread safe
Pattern pattern = Pattern.compile(JAVA_CONFIG_VARIABLE);
Matcher matcher = pattern.matcher(in);
StringBuffer buf = new StringBuffer();
while (matcher.find())
{
String replaceStr = matcher.group(1);
String prop = getProperty(replaceStr);
//if it isn't in our properties file, check if it is a system property
if (prop == null )
prop = System.getProperty(replaceStr);
if( prop == null )
{
System.out.printf("Failed to find property '%s' for '%s'\n", replaceStr, in);
}
else
{
matcher.appendReplacement(buf, prop);
}
}
matcher.appendTail(buf);
String result = buf.toString();
return result;
}