commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Klinemeier <zip...@gmail.com>
Subject Re: [configuration] no exception on missing key
Date Sat, 03 Sep 2005 00:00:04 GMT
Thanks, that worked pretty well.  I needed a static class to read the
file once anyway, so not a terrible approach.

-Kevin

On 9/1/05, Oliver Heger <hegero@med.uni-marburg.de> wrote:
> Emmanuel Bourg schrieb:
> > Oliver Heger wrote:
> >
> >> The purpose is that the configurations contained in a
> >> CompositeConfiguration should have the same exception behavior as the
> >> composite itself. Unfortunately when loaded from a
> >> ConfigurationFactory, it is not possible to define the
> >> CompositeConfiguration's exception flag, so it is always false.
> >>
> >> I guess this should be fixed, or at least the
> >> setThrowExceptionOnMissing() method overloaded in
> >> CompositeConfiguration to set the flags on the contained configs. Then
> >> it would be possible to turn this on after it was loaded by the factory.
> >
> >
> > Does it really make sense to change the flag on only one of the
> > configurations ? What about supporting a syntax like this instead:
> >
> > <configuration throwExceptionOnMissing="true">
> >   <system/>
> >   <xml fileName="prodConfig.xml" optional="true"/>
> > </configuration>
> >
> > Emmanuel Bourg
> >
> 
> Yes, on the long run this would surely be better.
> 
> I just found out that the value of the flag in the configurations
> contained in a CompositeConfiguration does not matter at all because a
> getProperty() call is only performed if a containsKey() call returns
> true. So it should be sufficient to set the composite's flag to get the
> desired behavior.
> 
> So, Kevin, as a workaround for your current problem you can do something
> like this:
> 
> Configuration config = factory.getConfiguration();
> ((AbstractConfiguration) config).setThrowExceptionOnMissing(true);
> 
> Oliver
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
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