Issue Details (XML | Word | Printable)

Key: CONFIGURATION-337
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Oliver Heger
Reporter: Ralph Goers
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons Configuration

Allow users of DefaultConfigurationBuilder to configure the class name of the CombinedConfiguration to create and to configure providers

Created: 02/Oct/08 07:18 AM   Updated: 14/Dec/08 04:18 AM
Return to search
Component/s: None
Affects Version/s: 1.6
Fix Version/s: 1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works config.patch 2008-10-02 07:19 AM Ralph Goers 11 kB
Text File Licensed for inclusion in ASF works config2.patch 2008-10-04 08:16 AM Ralph Goers 10 kB
Environment: Any

Resolution Date: 04/Oct/08 07:25 PM


 Description  « Hide
This enhancement allows config-class to be specified on the result element. The specified class must extend CombinedConfiguration.

This enhancment allows ConfigurationProviders to be configured by adding

<providers>
<provider tag="myprovider" config-class="MyProviderClass"/>
</providers

to the header.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Ralph Goers added a comment - 02/Oct/08 07:19 AM
The patch to implement this feature along with unit tests.

Oliver Heger added a comment - 03/Oct/08 05:33 PM
Ralph,

many thanks for your contribution. I had a look at the patch, and this is really some cool stuff. I am happy to apply it, but have the following minor suggestions:

  • So far the providers' classes are directly loaded, and instances are created through reflection. Why not reusing our bean declaration mechanism for this purpose? This would also allow setting properties on the provider objects created.
  • I would prefer if ExtendedCombinedConfiguration, which is used for testing the config-class attribute for the resulting configuration, was an inner class of TestDefaultConfigurationBuilder. It is only used in this test class and does not deserve the status of a top level class.

What do you think?


Ralph Goers added a comment - 03/Oct/08 05:44 PM
I am fine with both of these suggestions. I didn't use the bean declaration mechanism primarily because I hadn't looked at how that worked when I wrote that part of the patch.

Ralph Goers added a comment - 04/Oct/08 08:16 AM
Updated patch with requested changes.

Oliver Heger added a comment - 04/Oct/08 03:47 PM
Patch applied in revision 701654.

It could even be slightly simplified. As it turned out, defining a custom CombinedConfiguration class as resulting configuration is already supported. This is due to the bean definition mechanism, which automatically looks for a config-class attribute and evaluates it if present; otherwise the default class passed to the BeanHelper is used. Also at the creation of the providers there is no need to explicitly specify the provider class because it is found automatically by the XMLBeanDeclaration.

Leaving open until the patch was ported to the configuration-2 branch.


Ralph Goers added a comment - 04/Oct/08 06:32 PM
Thanks. I should have looked at the javadoc for createBean.

Also, I noticed you cleaned up the unit test a little bit. After looking at it it seems you could have also gotten rid of the creation of the new DefaultConfigurationBuilder in testExtendedClass since that happens in setUp.


Oliver Heger added a comment - 04/Oct/08 07:19 PM
Thanks for the spot. I missed this one. I updated the test correspondingly.

Oliver Heger added a comment - 04/Oct/08 07:25 PM
The patch was also applied to the configuration2 branch.

Ralph Goers added a comment - 14/Dec/08 04:18 AM
This is part of the 1.6 release.