On 01/22/2011 08:31 AM, Oliver Heger wrote:
Hello Mike,
Am 21.01.2011 06:48, schrieb Mike Power:
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
this seems to be a valid use case for me.
I am a bit reluctant to adding such a feature because this would mean
a change at a very central component. So there is the danger of
undesired side effects. To be on the safe side and to ensure backwards
compatibility with existing applications, there should at least be a
way to turn off this feature.
So it would be preferable if your problem could be solved with other
board means provided by Commons Configuration as Emmanuel pointed out
in his response.
That said, patches are always welcome. Just open a new feature request
in our bug tracking system [1] and attach your proposed patch.
Thanks
Oliver
[1] http://commons.apache.org/configuration/issue-tracking.html
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org
The solution will solve my particular use case. I'll try it it and post
again if I have more information to add.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org