You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Emmanuel Bourg <eb...@micropole-univers.com> on 2004/03/04 21:37:17 UTC

[configuration] SubsetConfiguration

I have reimplemented the subset code with a decorator, the pros :
- the resulting code is much cleaner
- it fixes some old quicks
- it fixes Bug 27427
- no property is copied => more memory efficient
- the subset is fully synchronized with its parent configuration

the cons: I should be at home at this hour ;)

I had to change a test for HierarchicalConfiguration, I hope it doesn't 
break the initial intent.

Emmanuel Bourg


Re: [configuration] SubsetConfiguration

Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
I tried to push the reasoning a bit further yesterday and observed that 
if there is a SubsetConfiguration shifting the parent keys to the left, 
we might imagine a SupersetConfiguration shifting the keys to the right 
by adding a prefix. Both classes could even be merged into a 
TranslatedConfiguration. But what use case could require the addition of 
a prefix to all the keys of a configuration ? I identified 2 use cases:

- ini files, a section is basically a configuration translated to the 
right by the section name.

- configuration "mounting" in a CompositeConfiguration, to mix 
heterogeneous configurations with identical keys into a unique 
configuration. For example, given 2 configurations:

mail.properties:
server=smtp.xyz.com

database.properties:
server=db.xyz.com

One would mount the configuration into a CompositeConfiguration to avoid 
conflicts:

composite.addConfiguration(new TranslatedConfiguration(mail, "mail"));
composite.addConfiguration(new TranslatedConfiguration(database, 
"database"));

composite.getString("mail.server");
composite.getString("database.server");


Emmanuel Bourg

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


RE: [configuration] SubsetConfiguration

Posted by Eric Pugh <ep...@upstate.com>.
One of the classes that Oliver Heger is responsible was failing..  Maybe
this bug: http://issues.apache.org/bugzilla/show_bug.cgi?id=27427...

If you want to try removing it again, send me a patch, and I'll try it as
well and if it passes with out subset on both, then let's apply..   I saw
the bug as well when subset was removed from CompositeConfiguration, there
was a failing testcase...

I think it was the sequence of events that led to the bug showing up,
between your subset refactoring and fixing the
HierarchicalConfiguration/ConfigurationXMLDocument bugs....

Eric

> -----Original Message-----
> From: Emmanuel Bourg [mailto:ebourg@micropole-univers.com]
> Sent: Monday, March 22, 2004 12:04 PM
> To: Jakarta Commons Developers List
> Subject: Re: [configuration] SubsetConfiguration
>
>
> Thank you Eric ! I noticed you reintroduced a subset() method in the
> CompositeConfiguration class, why was this necessary ? I tried to remove
> it and all test cases still pass successfully.
>
> Emmanuel Bourg
>
>
> Eric Pugh wrote:
>
> > Applied!  Can you review..
> >
> > Eric
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


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


Re: [configuration] SubsetConfiguration

Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
Thank you Eric ! I noticed you reintroduced a subset() method in the 
CompositeConfiguration class, why was this necessary ? I tried to remove 
it and all test cases still pass successfully.

Emmanuel Bourg


Eric Pugh wrote:

> Applied!  Can you review..
> 
> Eric
> 

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


RE: [configuration] SubsetConfiguration

Posted by Eric Pugh <ep...@upstate.com>.
Applied!  Can you review..

Eric

> -----Original Message-----
> From: Emmanuel Bourg [mailto:ebourg@micropole-univers.com]
> Sent: Friday, March 05, 2004 5:28 PM
> To: Jakarta Commons Developers List
> Subject: Re: [configuration] SubsetConfiguration
> 
> 
> Here is a new implementation of the SubsetConfiguration:
> 
> - a null or empty key can now be used to retrieve the subset 
> root element.
> 
> - subset.getKeys() and subset.getKeys(prefix) are now fixed, 
> previously 
> they returned the keys of the parent configuration and not 
> the keys of 
> the subset.
> 
> - AbstractConfiguration.getKeys(prefix) has been changed to use a 
> FilterIterator and fix Bug 27427.
> 
> Emmanuel Bourg
> 
> 
> 

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


RE: [configuration] SubsetConfiguration

Posted by Eric Pugh <ep...@upstate.com>.
Oh, one more thing, because I hadn't applied the Locale patch yet, I had to
drop those methods from SubsetConfiguration.

Eric

> -----Original Message-----
> From: Emmanuel Bourg [mailto:ebourg@micropole-univers.com]
> Sent: Friday, March 05, 2004 5:28 PM
> To: Jakarta Commons Developers List
> Subject: Re: [configuration] SubsetConfiguration
>
>
> Here is a new implementation of the SubsetConfiguration:
>
> - a null or empty key can now be used to retrieve the subset
> root element.
>
> - subset.getKeys() and subset.getKeys(prefix) are now fixed,
> previously
> they returned the keys of the parent configuration and not
> the keys of
> the subset.
>
> - AbstractConfiguration.getKeys(prefix) has been changed to use a
> FilterIterator and fix Bug 27427.
>
> Emmanuel Bourg
>
>
>


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


Re: [configuration] SubsetConfiguration

Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
Here is a new implementation of the SubsetConfiguration:

- a null or empty key can now be used to retrieve the subset root element.

- subset.getKeys() and subset.getKeys(prefix) are now fixed, previously 
they returned the keys of the parent configuration and not the keys of 
the subset.

- AbstractConfiguration.getKeys(prefix) has been changed to use a 
FilterIterator and fix Bug 27427.

Emmanuel Bourg


Re: [configuration] SubsetConfiguration

Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
Jörg Schaible wrote:

>>- it fixes Bug 27427
> 
> OK. Then don't apply it <g>

Actually it doesn't fix 27427 completely, the getKeys(prefix) method 
will still return an extra key. I'll change the implementation of this 
method and use a FilterIterator from [collections] instead, that will 
remove the copy of the matched keys and reduce the memory used.

Emmanuel Bourg

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


RE: [configuration] SubsetConfiguration

Posted by Jörg Schaible <jo...@gmx.de>.
Jörg Schaible wrote:

> Hi Eric,
> 
> Eric Pugh wrote:
>> Guys..  I have been a little remiss keeping up with the flow of patches..
>> However, this weekend I will go through them all and try and get all the
>> good stuff updated.
> 
> :)
> 
> Emmanuel said he already made 27427 obsolete, but I could not see an issue
> in Bugzilla yet.

Ups. Did not recoginze Emmanuel's attachments ...

Regards,
Jörg



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


RE: [configuration] SubsetConfiguration

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Eric,

Eric Pugh wrote:
> Guys..  I have been a little remiss keeping up with the flow of patches..
> However, this weekend I will go through them all and try and get all the
> good stuff updated.

:)

Emmanuel said he already made 27427 obsolete, but I could not see an issue
in Bugzilla yet.

> Also, I think the roadmap is good..  I kinda wish more stuff was post 1.0,
> I really want to get the release out, but if we have people willing to do
> the work to incorporate these changes into 1.0, then I'm happy to hold off
> and keep the patches going.

Well, I would also like to have a 1.0 soon, but without the necessity for
Dom4J using JDK 1.4. This includes DOMConfiguration,
HierarchicalDOMConfiguration and a ConfigurationFactory (similar class) not
depedning on Dom4J either.

> I'll try and get the update on the website as well as an xdoc..  At one
> point I think there was a roadmap plugin?

Really? Never heard of. But Maven is growing rapidly.

Regards,
Jörg


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


RE: [configuration] SubsetConfiguration

Posted by Eric Pugh <ep...@upstate.com>.
Guys..  I have been a little remiss keeping up with the flow of patches..
However, this weekend I will go through them all and try and get all the
good stuff updated.

Also, I think the roadmap is good..  I kinda wish more stuff was post 1.0, I
really want to get the release out, but if we have people willing to do the
work to incorporate these changes into 1.0, then I'm happy to hold off and
keep the patches going.

I'll try and get the update on the website as well as an xdoc..  At one
point I think there was a roadmap plugin?

Eric

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Jörg Schaible
> Sent: Thursday, March 04, 2004 9:07 PM
> To: commons-dev@jakarta.apache.org
> Subject: Re: [configuration] SubsetConfiguration
>
>
> Emmanuel Bourg wrote:
>
> > I have reimplemented the subset code with a decorator, the pros :
> > - the resulting code is much cleaner
> > - it fixes some old quicks
> > - it fixes Bug 27427
>
> OK. Then don't apply it <g>
>
> > - no property is copied => more memory efficient
> > - the subset is fully synchronized with its parent configuration
>
> Sounds fine.
>
> > the cons: I should be at home at this hour ;)
>
> Good night, Sir!
>
> > I had to change a test for HierarchicalConfiguration, I
> hope it doesn't
> > break the initial intent.
>
> Better to change the test to sanctify the "right" behaviour
> as cement the
> quirks.
> :)
>
> Regards,
> Jörg
>
> BTW: HierarchicalDOMConfiguration is already running ...
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


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


Re: [configuration] SubsetConfiguration

Posted by Jörg Schaible <jo...@gmx.de>.
Emmanuel Bourg wrote:

> I have reimplemented the subset code with a decorator, the pros :
> - the resulting code is much cleaner
> - it fixes some old quicks
> - it fixes Bug 27427

OK. Then don't apply it <g>

> - no property is copied => more memory efficient
> - the subset is fully synchronized with its parent configuration

Sounds fine.

> the cons: I should be at home at this hour ;)

Good night, Sir!
 
> I had to change a test for HierarchicalConfiguration, I hope it doesn't
> break the initial intent.

Better to change the test to sanctify the "right" behaviour as cement the
quirks.
:)

Regards,
Jörg

BTW: HierarchicalDOMConfiguration is already running ...


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


Re: [configuration] SubsetConfiguration

Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
Jörg Schaible wrote:

> after recognizing, that you've attached the diff, I had a look at the
> changes in the test case. I am not quite sure, that this is really good.
> Intentionally I thought, you would return an empty configuration only, if
> the pattern equals the key, but you do so now also if the pattern does not
> match at all.
> 
> This will break my usage of Configuration for certain and I am probably not
> alone here.

You expect subset() to return a null configuration instead of an empty 
configuration ?

I see one issue with the current implementation, it is not possible to 
access the property in the parent configuration with a key matching the 
prefix of the subset (the subset root property):

conf.setProperty("x.y.z", "1");
subset = conf.subset("x.y.z");

Here subset is empty and I can't read the value of "x.y.z". If I call 
subset.getProperty("") it will return null because the key "x.y.z." 
doesn't exist in the parent configuration. I think I'll change the 
implementation I suggested to allow the use of a null (or "" ?) key to 
access the subset root property, that's subset.getProperty(null) returns 
"1".

Emmanuel Bourg


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


Re: [configuration] SubsetConfiguration

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Emmanuel,

Emmanuel Bourg wrote:
> I had to change a test for HierarchicalConfiguration, I hope it doesn't
> break the initial intent.

after recognizing, that you've attached the diff, I had a look at the
changes in the test case. I am not quite sure, that this is really good.
Intentionally I thought, you would return an empty configuration only, if
the pattern equals the key, but you do so now also if the pattern does not
match at all.

This will break my usage of Configuration for certain and I am probably not
alone here.

Regards,
Jörg


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