commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <Joerg.Schai...@Elsag-Solutions.com>
Subject RE: [configuration] SubsetConfiguration
Date Fri, 05 Mar 2004 12:51:00 GMT
Emmanuel Bourg wrote on Friday, March 05, 2004 1:27 PM:

> Jörg Schaible wrote:
> 
>> Looking at the changes for teh test cases, I have the impression that
>> 
>> conf.setProperty("x.y.z", "1");
>> subset = conf.subset("x.y.z.not_there");
>> 
>> will also return an empty configuration, whereas this return value
>> was previously always just null.
> 
> Yes indeed, but since the subset is now synchronized with the parent
> configuration I think it's better to return an empty
> configuration, thus
> you can add new keys to the parent through a subset. For example :
> 
> Configuration config = new BaseConfiguration();
> Configuration subset = config.subset("database");
> subset.setProperty("driver", "oracle.jdbc.driver.OracleDriver");
> subset.setProperty("url", "jdbc:oracle:thin:@host:1521:service");
> subset.setProperty("username", "foo");
> subset.setProperty("password", "bar");
> 
> config.getProperty("database.driver");

Sure, but here is the compatibility issue:

Configuration config = new BaseConfiguration();
Configuration subset = config.subset("database");
if(subset == null) {
	// continue with limited functionality
} else {
	jdbc.connect(subset.getProperty("database").toString());
}

===> an existing app may just fail now with NPE

But I admit that your example above look smart though :)

Regards,
Jörg


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


Mime
View raw message