Consider the following code:
public class Main {
public static void main(String[] args)
{
Configuration conf = new BaseConfiguration();
conf.setProperty("interpolationdone", "true");
conf.setProperty("interpolation${interpolated}", "false");
conf.setProperty("interpolated", "done");
System.out.println(conf.getString("interpolation${interpolated}"));
}
}
Currently it prints out false I would like it to print out true.
What that means is that when conf.getString is called and there is a
variable expression in the key that configurations would look up the
value of the variable and substitute it into the name of the key being
looked up?
The use case I am trying to solve goes something like this. I have a
configuration file for several identical servers:
server.1.host=blah1
server.1.port=1
server.2.host=blah2
server.2.port=2
server.3.host=blah3
server.3.port=3
I could choose which server I connect with by setting some configuration
currentServer=2
Then when I look up the host and port I can write
conf.getString("server.${currentServer}.host");
conf.getInt("server.${currentServer}.port");
Does that make sense?
I realize the usefulness of providing a patch with said feature request,
I am not at that point yet. However if this is an interesting feature
to add then I would be more inclined to write it.
Mike Power
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]