You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by to...@edbtelesciences.com on 2005/04/07 14:54:38 UTC

[Configuration] CompositeConfiguration - setting FileChangedReloadingStrategy on each XMLConfiguration

Hei,

I'm trying to use CompositeConfiguration to read the following configuration
file:

<file>

	<?xml version="1.0" encoding="UTF-8"?>
	<configuration>
	  <xml fileName="<path-to-a-place-outside-war>/locations.xml"/>
	  <xml fileName="<path-to-a-place-outside-war>/calendar.xml"/>
	</configuration>

</file>

Each of these xml-elements will result in an XMLConfiguration. The intent is
to make it possible
for customers to change an entry in the locations.xml file and have the new
configuration
reloaded. I know that a FileChangedReloadingStrategy may be set on each of
the XMLConfigurations
If they where separate, but how can I set this reloadingStrategy when the
factory makes a 
CompositeConfiguration that contain the two XMLConfigurations.

I have assumed that I have to use CompositeConfiguration i order to
automatically get the two
XMLConfigurations.

I hope for a code example as an explaination.

Regards from Tore Garder Larsen
Software Engineer
EDB Telecom AS


[Configuration] Save(), found bugs / preposed changes and new features

Posted by Jamie Guillemette <JM...@hotmail.com>.
[Configuration] CompositeConfiguration - setting FileChangedReloadingStrategy on each XMLConfigurationHey everyone,

I downloaded the commons configuration project a few days ago in hopes of using it to create a generic configuration interface. 

In order to achieve this, I need an api that can a) read configuration information from multiple datasources b) save changes back to the original datasources. (which sounds exaclty what the configuration project is all about)

In experimenting with the api I've come across serval serveral inconsitencies with the save() feature... (ive had no problem with simply reading values)

a) if your project is devided into src / bin and the root of the running path is neither of these.. save a properties file will result in a new file being created in the root or the current running path.. not overiding the existing file.

b) if you use URL to load your configuration ie 
    URL url2 = this.getClass().getResource("/sample.properties");
      config.addConfiguration(new PropertiesConfiguration(url2));
when saving...two things happen. 1) the file is not saved. 2) the in memmory representation of the values all become null. (where previous to the save you could retreive the values without issue)

Its seems like there is a major bug in the save() logic ... worst yet.. whatever problem that is being encountered is not throwing a configuration exception.
If everyone agrees.. i would like to take a serious look at the existing save logic for each configuration type add the following:

i) make any adjustments necessary to guarrentee that where the configuration data is read from is where it is saved to reguardless of project layout.
ii) add save() to CompositeConfiguration that will delegate down to all configurations under its control.

Let me know your thoughts guys.
J.



Re: [Configuration] CompositeConfiguration - setting FileChangedReloadingStrategy on each XMLConfiguration

Posted by Oliver Heger <ol...@t-online.de>.
Declaration of reloading strategies in the configuration definition file 
is on the agenda, see here:
http://issues.apache.org/bugzilla/show_bug.cgi?id=34350

About a DTD for the definition files I am not sure. We plan to make the 
loading of a ConfigurationFactory more flexible and to support pluggable 
configuration sources. It should be possible to define your own tags for 
configuration sources. A DTD would limit flexibility and extensibility 
here, unless we choose a generic form like

<config class="o.a.c.configuration.PropertiesConfiguration" fileName="..."/>

I personally would prefer tags with speaking names like <properties> or 
<xml>.

How to become an active member, i.e. a committer? In short it's like 
that: You have to earn yourself a certain degree of attention by 
providing contributions and activity on the list. Then a committer calls 
a vote and if the community decides to grant you commit rights, you are in.

Oliver

Jamie Guillemette wrote:

> sounds like a decent suggestion...
>
> any thoughts from the active members?
> BTW how does one get on the active member list..
>
> ----- Original Message ----- From: "Lukas Bradley" <lu...@somnia.com>
> To: <co...@jakarta.apache.org>
> Sent: Friday, April 08, 2005 3:48 PM
> Subject: Re: [Configuration] CompositeConfiguration - setting 
> FileChangedReloadingStrategy on each XMLConfiguration
>
>
>>> [snipped Java code on manual setting of all configuration files to 
>>> reload strat]
>>
>>
>> I would like to request two things.  First, a DTD for the 
>> ConfigurationFactory XML file.  Second, the ability to do something 
>> like this:
>>
>> <configuration>
>>   <!-- Reload usergui every -->
>>   <properties fileName="usergui.properties"
>> reload="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy" 
>> />
>>   <!-- Since reload attribute is not included, it defaults to 
>> InvariantReloadingStrategy -->
>>   <xml fileName="gojackets.xml" />
>>
>>   <xml fileName="another.xml"
>> reload="my.own.superkeen.EarthShatteringReloadingStrategy" />
>> </configuration>
>>
>> So that the reloading interfaces may be defined in the XML itself.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Configuration] CompositeConfiguration - setting FileChangedReloadingStrategy on each XMLConfiguration

Posted by Jamie Guillemette <JM...@hotmail.com>.
sounds like a decent suggestion...

any thoughts from the active members?
BTW how does one get on the active member list..

----- Original Message ----- 
From: "Lukas Bradley" <lu...@somnia.com>
To: <co...@jakarta.apache.org>
Sent: Friday, April 08, 2005 3:48 PM
Subject: Re: [Configuration] CompositeConfiguration - setting 
FileChangedReloadingStrategy on each XMLConfiguration


>> [snipped Java code on manual setting of all configuration files to reload 
>> strat]
>
> I would like to request two things.  First, a DTD for the 
> ConfigurationFactory XML file.  Second, the ability to do something like 
> this:
>
> <configuration>
>   <!-- Reload usergui every -->
>   <properties fileName="usergui.properties"
> reload="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy" 
> />
>   <!-- Since reload attribute is not included, it defaults to 
> InvariantReloadingStrategy -->
>   <xml fileName="gojackets.xml" />
>
>   <xml fileName="another.xml"
> reload="my.own.superkeen.EarthShatteringReloadingStrategy" />
> </configuration>
>
> So that the reloading interfaces may be defined in the XML itself.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Configuration] CompositeConfiguration - setting FileChangedReloadingStrategy on each XMLConfiguration

Posted by Lukas Bradley <lu...@somnia.com>.
> [snipped Java code on manual setting of all configuration files to reload strat]

I would like to request two things.  First, a DTD for the 
ConfigurationFactory XML file.  Second, the ability to do something like 
this:

<configuration>
   <!-- Reload usergui every -->
   <properties fileName="usergui.properties"
	reload="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy" 
/>
   <!-- Since reload attribute is not included, it defaults to 
InvariantReloadingStrategy -->
   <xml fileName="gojackets.xml" />

   <xml fileName="another.xml"
	reload="my.own.superkeen.EarthShatteringReloadingStrategy" />
</configuration>

So that the reloading interfaces may be defined in the XML itself.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Configuration] CompositeConfiguration - setting FileChangedReloadingStrategy on each XMLConfiguration

Posted by Lukas Bradley <lu...@somnia.com>.
> [snipped Java code on manual setting of all configuration files to reload strat]

I would like to request two things.  First, a DTD for the 
ConfigurationFactory XML file.  Second, the ability to do something like 
this:

<configuration>
   <!-- Reload usergui every -->
   <properties fileName="usergui.properties"
	reload="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy" 
/>
   <!-- Since reload attribute is not included, it defaults to 
InvariantReloadingStrategy -->
   <xml fileName="gojackets.xml" />

   <xml fileName="another.xml"
	reload="my.own.superkeen.EarthShatteringReloadingStrategy" />
</configuration>

So that the reloading interfaces may be defined in the XML itself.




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Configuration] CompositeConfiguration - setting FileChangedReloadingStrategy on each XMLConfiguration

Posted by Miji Mathews <mi...@gmail.com>.
ConfigurationFactory factory = new ConfigurationFactory("config.xml");
CompositeConfiguration cc = (CompositeConfiguration)factory.getConfiguration();
for (int i = 0; i < cc.getNumberOfConfigurations(); i++)
       {
         if (cc.getConfiguration(i) instanceof XMLConfiguration)
         {
            ((XMLConfiguration)cc.getConfiguration(i)).setReloadingStrategy(new
FileChangedReloadingStrategy());
         }
       }



On Apr 7, 2005 8:54 AM, tore.larsen@edbtelesciences.com
<to...@edbtelesciences.com> wrote:
>  
> 
> Hei, 
> 
> I'm trying to use CompositeConfiguration to read the following configuration
> file: 
> 
> <file> 
>  
> 
> <?xml version="1.0" encoding="UTF-8"?> 
> <configuration> 
>   <xml
> fileName="<path-to-a-place-outside-war>/locations.xml"/> 
>   <xml
> fileName="<path-to-a-place-outside-war>/calendar.xml"/> 
> </configuration> 
> 
> </file> 
> 
> Each of these xml-elements will result in an XMLConfiguration. The intent is
> to make it possible 
> for customers to change an entry in the locations.xml file and have the new
> configuration 
> reloaded. I know that a FileChangedReloadingStrategy may be set on each of
> the XMLConfigurations 
> If they where separate, but how can I set this reloadingStrategy when the
> factory makes a 
> CompositeConfiguration that contain the two XMLConfigurations. 
> 
> I have assumed that I have to use CompositeConfiguration i order to
> automatically get the two 
> XMLConfigurations. 
> 
> I hope for a code example as an explaination. 
> 
> Regards from Tore Garder Larsen 
> Software Engineer 
> EDB Telecom AS 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org