commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hart, Leo" <Leo.H...@FMR.COM>
Subject RE: [configuration] MultiFile Configuration
Date Thu, 14 May 2009 14:27:35 GMT
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


Mime
View raw message