commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: Configuration: Reading multiple files with the same name (from different jars)
Date Mon, 17 May 2010 19:39:53 GMT
Hi Ralph,

Am 17.05.2010 12:34, schrieb rhwinzin:
>
> Hi,
>
> I'm currently designing an application which has to be very flexible /
> extendable. My idea was to provide certain "hooks" (i.e. configuration files
> with well defined names) that can be placed in various jar modules or in the
> file-system classpath. Maybe I should give an example:
>
> Say we have a configuration file "error-msg.properties". This file might be
> provided in various JARs (/META-INF/error-msg.properties") and all of them
> should be loaded. Furthermore, the application should check the file-system
> classpath if there's also one (or more) such property file. The whole thing
> should support reload strategy and the application should also check, if
> there was a new properties file created in the classpath.
>
> I'm not quite sure, whether Commons-Configuration supports this out of the
> box. If so, maybe someone could give me a hint, on how to do this. If not,
> hints for writing the respective extension are highly appreciated.
>
> Thanks in advance,
> Ralph

unfortunately, there is no support for such features out of the box.

But I think you could use DefaultConfigurationBuilder; it provides some 
functionality similar to your use case. Per default, 
DefaultConfigurationBuilder reads an XML definition file that defines 
the configuration sources to be loaded. One approach would be to 
generate such a file with the configuration sources you need dynamically 
and pass it to the builder. An alternative would be to initialize the 
builder manually: it is derived from XMLConfiguration, so it is possible 
to set properties that correspond to the definitions of configuration 
sources.

So the basic idea is that you use DefaultConfigurationBuilder to load 
the configuration sources available and define reloading strategies for 
them. Looking up the sources would be in the responsibility of your 
application.

Probably you will not be able to satisfy all your requirements. For 
instance, Commons Configuration does not provide any functionality to 
monitor the class path and reread configuration files if something has 
changed.

HTH
Oliver

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


Mime
View raw message