You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Hart, Leo" <Le...@FMR.COM> on 2009/05/13 19:45:53 UTC

[configuration] MultiFile Configuration

I am trying to figure out if commons-configuration currently provides a
means to specify a folder and load all property files into
configuration.  For example, I currently have the following:

	<?xml version="1.0" encoding="UTF-8"?>
	<configuration>
	 <override>
	  <system />
	 
	  <properties fileName="/properties/propertyFile.properties"
	   throwExceptionOnMissing="false" config-name="override"
	   config-optional="true" />
	....

and would be interested in having something like:
 

	<?xml version="1.0" encoding="UTF-8"?>
	<configuration>
	 <override>
	  <system />
	 
	  <properties fileName="/properties/*.properties"
	   throwExceptionOnMissing="false" config-name="override"
	   config-optional="true" />
	....

Is there currently a way to do this?  If not, what class\classes would
you recommend extending in order to provide this sort of functionality?
 
Thanks!
Leo

RE: [configuration] MultiFile Configuration

Posted by "Hart, Leo" <Le...@FMR.COM>.
Thanks for your reply!  I'll look into your suggestions and see what I
can come up with. 

-----Original Message-----
From: Oliver Heger [mailto:oliver.heger@oliver-heger.de] 
Sent: Wednesday, May 13, 2009 3:56 PM
To: Commons Users List
Subject: Re: [configuration] MultiFile Configuration

Hart, Leo schrieb:
> I am trying to figure out if commons-configuration currently provides
a
> means to specify a folder and load all property files into
> configuration.  For example, I currently have the following:
> 
> 	<?xml version="1.0" encoding="UTF-8"?>
> 	<configuration>
> 	 <override>
> 	  <system />
> 	 
> 	  <properties fileName="/properties/propertyFile.properties"
> 	   throwExceptionOnMissing="false" config-name="override"
> 	   config-optional="true" />
> 	....
> 
> and would be interested in having something like:
>  
> 
> 	<?xml version="1.0" encoding="UTF-8"?>
> 	<configuration>
> 	 <override>
> 	  <system />
> 	 
> 	  <properties fileName="/properties/*.properties"
> 	   throwExceptionOnMissing="false" config-name="override"
> 	   config-optional="true" />
> 	....
> 
> Is there currently a way to do this?  If not, what class\classes would
> you recommend extending in order to provide this sort of
functionality?

Unfortunately, this is not supported so far. I had also thought about a 
feature like scanning a directory and collecting all configuration files

found. This would be a nice enhancement for [configuration].

For the implementation I would probably use DefaultConfigurationBuilder.

You can write a simple directory scanner class that adds all 
configuration files it detects to a DefaultConfigurationBuilder 
instance. Because DefaultConfigurationBuilder extends XMLConfiguration 
you can simulate the structure of a configuration definition file with 
corresponding addProperty() calls (I think the unit tests in 
TestDefaultConfigurationBuilder do similar things). After the 
DefaultConfigurationBuilder instance has been initialized you can obtain

a combined configuration object from it.

Oliver

>  
> Thanks!
> Leo
> 


---------------------------------------------------------------------
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] MultiFile Configuration

Posted by Oliver Heger <ol...@oliver-heger.de>.
Hart, Leo schrieb:
> I am trying to figure out if commons-configuration currently provides a
> means to specify a folder and load all property files into
> configuration.  For example, I currently have the following:
> 
> 	<?xml version="1.0" encoding="UTF-8"?>
> 	<configuration>
> 	 <override>
> 	  <system />
> 	 
> 	  <properties fileName="/properties/propertyFile.properties"
> 	   throwExceptionOnMissing="false" config-name="override"
> 	   config-optional="true" />
> 	....
> 
> and would be interested in having something like:
>  
> 
> 	<?xml version="1.0" encoding="UTF-8"?>
> 	<configuration>
> 	 <override>
> 	  <system />
> 	 
> 	  <properties fileName="/properties/*.properties"
> 	   throwExceptionOnMissing="false" config-name="override"
> 	   config-optional="true" />
> 	....
> 
> Is there currently a way to do this?  If not, what class\classes would
> you recommend extending in order to provide this sort of functionality?

Unfortunately, this is not supported so far. I had also thought about a 
feature like scanning a directory and collecting all configuration files 
found. This would be a nice enhancement for [configuration].

For the implementation I would probably use DefaultConfigurationBuilder. 
You can write a simple directory scanner class that adds all 
configuration files it detects to a DefaultConfigurationBuilder 
instance. Because DefaultConfigurationBuilder extends XMLConfiguration 
you can simulate the structure of a configuration definition file with 
corresponding addProperty() calls (I think the unit tests in 
TestDefaultConfigurationBuilder do similar things). After the 
DefaultConfigurationBuilder instance has been initialized you can obtain 
a combined configuration object from it.

Oliver

>  
> Thanks!
> Leo
> 


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