Hi,
getProperty() always returns the raw value, to get the interpolated
value you have to call getString() (or another getter).
Emmanuel Bourg
Le 29/11/2011 12:29, Vinicius Carvalho a écrit :
> Hi there! I'm trying to get Variable interpolation to work. But it seems
> that either I missed something at the docs or there's a bug here.
>
> All I need is to replace a ${app} on my properties file to contain a string
> instead
>
> so whenever I have ${app}.maxUsers=10 I want AppName.maxUsers=10
>
> Here's some code:
>
> private class AppInterpolator extends StrLookup{
> @Override
> public String lookup(String var) {
> return "#{"+appName+"}";
> }
> }
>
> ConfigurationInterpolator.registerGlobalLookup("app", new
> AppInterpolator());
> config = new CompositeConfiguration();
> PropertiesConfiguration localProps = new
> PropertiesConfiguration(this.getClass().getClassLoader().getResource(PROPERTIES_FILE_NAME));
> this.config.addConfiguration(localProps);
>
>
> But after using config.getProperty("") I've noticed that the property here
> is ${app}.maxUsers and not AppName.maxUsers
>
> I've also noticed that it seems that PropertiesFile does not reference
> ConfigurationInterpolator at all.
>
> Any ideas on how to fix this?
>
> Regards
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
|