You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "gz.lyn" <ka...@gmail.com> on 2008/11/27 07:34:03 UTC
Configuration Automatic Reloading
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
Re: Configuration Automatic Reloading
Posted by "gz.lyn" <ka...@gmail.com>.
Thanks so much Oliver, I will try it[?]
On Sat, Nov 29, 2008 at 4:57 AM, Oliver Heger
<ol...@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
>> <ol...@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
Re: Configuration Automatic Reloading
Posted by Oliver Heger <ol...@oliver-heger.de>.
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
> <ol...@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
Re: Configuration Automatic Reloading
Posted by "gz.lyn" <ka...@gmail.com>.
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*.
On Thu, Nov 27, 2008 at 3:02 PM, Oliver Heger
<ol...@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
>
>
--
Chrs,
-Jimmy lin
Re: Configuration Automatic Reloading
Posted by Oliver Heger <ol...@oliver-heger.de>.
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