commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "gz.lyn" <katc...@gmail.com>
Subject Re: Configuration Automatic Reloading
Date Sun, 30 Nov 2008 16:41:21 GMT
Thanks so much Oliver, I will try it[?]

On Sat, Nov 29, 2008 at 4:57 AM, Oliver Heger
<oliver.heger@oliver-heger.de>wrote:

> gz.lyn schrieb:
>
>> Hi Olver,
>>
>> My code looks like:
>>
>>
>>  PropertiesConfiguration config = new
>>> PropertiesConfiguration("config.properties");
>>> config.setReloadingStrategy(new FileChangedReloadingStrategy());
>>>
>>
>>
>>
>>  *config.properties*
>>>
>>> foo = bar
>>> include = distributors.properties
>>>
>>>
>>
>>  *distributors.properties*
>>>
>>> dist.name = abc
>>> dist.name = def
>>>
>>>
>> It works fine If I move the the key-values from *distributors.properties*
>> to
>> *config.properties*.
>>
>
> When include files are processed, the content of these files is directly
> embedded into the PropertiesConfiguration object. The result is the same as
> if the configuration was loaded from a single file. The connection to the
> include files is lost, and thus the reloading strategy cannot detect any
> changes at the include files.
>
> As a workaround you can use the DefaultConfigurationBuilder class [1] to
> load your configuration. This is slightly more complex than using
> PropertiesConfiguration directly, but offers more features and also supports
> reloading strategies for multiple configuration sources.
>
> Just create a configuration definition file that declares your original
> properties file and the import file as configuration sources and declare
> reloading strategies for both. (Note that the include declaration should be
> removed from the original properties file.) The configuration created by the
> builder will contain the properties found in both files.
>
> The tutorial in [1] explains how this is done.
>
> HTH
> Oliver
>
> [1]
> http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html#Using_DefaultConfigurationBuilder
>
>
>
>>
>> On Thu, Nov 27, 2008 at 3:02 PM, Oliver Heger
>> <oliver.heger@oliver-heger.de>wrote:
>>
>>  gz.lyn schrieb:
>>>
>>> Hi,
>>>
>>>> It seems changing the content of a included property file would not
>>>> affect
>>>> Config file Automatic Reloading? Or did I missed some steps?
>>>>
>>>>
>>>> Thanks for answering,
>>>> Jimmy
>>>>
>>>> Can you provide a short code fragment demonstrating how you setup your
>>>>
>>> configuration?
>>>
>>> Oliver
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
Chrs,
-Jimmy lin

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message