commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [configuration] Feature request key name variable interpolation
Date Sat, 22 Jan 2011 16:31:25 GMT
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.port=1
> server.2.port=2
> 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.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message