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: problems with configuration
Date Sat, 04 Aug 2007 15:13:47 GMT
Hi James,

James Mansion wrote:
> Using configuration 1.4, XP, SunJVM 1.5.0_12
> 
> I'm trying to use configuration as a  newbie.
> 
> I have in my code:
> 
>    DefaultConfigurationBuilder builder = new
> DefaultConfigurationBuilder() ;
>    builder.setURL(getClass().getResource("standard-config.xml")) ;
>    HierarchicalConfiguration cfg =
> builder.configurationAt("processor-bean") ;

Try builder.getConfiguration().configurationAt(...) instead of 
builder.configurationAt().

Only the getConfiguration() method causes the configuration sources to 
be loaded. The object returned here contains all the properties.

HTH
Oliver

> 
> This fails with:
> 
>    java.lang.IllegalArgumentException: Passed in key must select
> exactly one node: processor-bean
> 
> 
> The standard-config.xml is:
> 
> <configuration>
>    <!--Load the optional specified config file-->
>    <xml fileName="standard-processor.xml" optional="true">
>    </xml>
> </configuration>
> 
> and standard-processor.xml is:
> 
> <standard-processor>
>    <processor-bean config-class="com.msgware.mwdoc.Processor"
> verbose="true">
>       <fileLoader config-class="com.msgware.mwdoc.FileLoader">
>       </fileLoader>
>       <blockInferenceEngine
> config-class="com.msgware.BlockInferenceEngine">
>       </blockInferenceEngine>
>    </processor-bean>
> </standard-processor>
> 
> 
> Unfortunately the fetchNodeList returns nothing.
> 
> If of the configurationAt instead I go:
> 
>            Configuration tmp = builder.getConfiguration() ;
> 
>            Iterator i = tmp.getKeys() ;
> 
>            while (i.hasNext())
>            {
>                System.out.println("Got key: "+i.next()) ;
>            }
> 
> Then I get broadly what I had expected:
> 
> Got key: processor-bean.fileLoader[@config-class]
> Got key: processor-bean.blockInferenceEngine[@config-class]
> Got key: processor-bean[@config-class]
> Got key: processor-bean[@verbose]
> 
> What am I doing wrong?
> 
> 
> 
> ---------------------------------------------------------------------
> 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