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: get an XMLConfig. from ConfigurationFactory
Date Mon, 19 Mar 2007 20:46:32 GMT
DECAFFMEYER MATHIEU wrote:
> Hi,
> 
> I am using this snippet of code to get dynamically the configuration 
> settings of my app. :
> 
> URL url =
>         Thread.currentThread().getContextClassLoader().getResource(
>                 "ress/config.xml");
> ConfigurationFactory factory =* **new* ConfigurationFactory();
> factory.setConfigurationURL(url);
> Configuration conf =* null*;
> *try* {
>         conf = factory.getConfiguration();
> }* catch* (ConfigurationException e) {
>         e.printStackTrace();
> }
> 
> 
> The problem here is that I am trying to get an XMLConfiguration and not 
> a Configuraton object,
> to do operations on the configuration file itself (change the settings), 
> which is an XML file.
> 
> any tips on how to get an XMLConfiguration from a the 
> ConfigurationFactory ?
> 
> Thank u !
> 
> *__________________________________*
> 
> *   Matt*////
> 
You can cast the Configuration object you obtain from the factory to a 
CompositeConfiguration. This class provides the getConfiguration(int 
index) method, which gives you access to the child configurations. The 
XMLConfiguration you have loaded using the factory will be one of those.

HTH
Oliver


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


Mime
View raw message