You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by rhwinzin <ra...@senacor.com> on 2010/05/17 12:34:44 UTC
Configuration: Reading multiple files with the same name (from
different jars)
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
--
View this message in context: http://apache-commons.680414.n4.nabble.com/Configuration-Reading-multiple-files-with-the-same-name-from-different-jars-tp2219402p2219402.html
Sent from the Commons - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: Configuration: Reading multiple files with the same name (from
different jars)
Posted by Oliver Heger <ol...@oliver-heger.de>.
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