You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Joel Trunick <jo...@webifysolutions.com> on 2005/12/14 22:42:31 UTC

[CONFIGURATION] Conglomeration Properties file

Has someone written a Properties File configuration that will combine a
bunch of properties file on the classpath into one properties "file"?
Basically, it should take a single file name, and do a
Class.getResources(), combining all the properties into one.

I only ask because it sounds obvious, but I don't see one in the
package. Shouldn't this be trivial?

Joel


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


Re: [CONFIGURATION] Conglomeration Properties file

Posted by Emmanuel Bourg <eb...@apache.org>.
Joel Trunick wrote:
> Has someone written a Properties File configuration that will combine a
> bunch of properties file on the classpath into one properties "file"?
> Basically, it should take a single file name, and do a
> Class.getResources(), combining all the properties into one.
> 
> I only ask because it sounds obvious, but I don't see one in the
> package. Shouldn't this be trivial?

Hi Joel, that's quite easy to implement with a CompositeConfiguration. 
The code would look like this :

CompositeConfiguration conf = new CompositeConfiguration();
Enumeration<URL> e = 
Thread.currentThread().getContextClassLoader().getResources("config.properties");

while (e.hasMoreElements()) {
     conf.addConfiguration(new PropertiesConfiguration(e.nextElement()));
}

Emmanuel Bourg


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