Am 27.09.2015 um 18:39 schrieb Weygandt, Jon:
> It seems that with interfaces like ImmutableHierarchicalConfiguration one
> should be able to use the configuration independent of the way in which it
> is implemented.
> 
> From the 
> example(https://commons.apache.org/proper/commons-configuration/userguide/h
> owto_beans.html#An_Example):
> 
> Parameters params = new Parameters();
> FileBasedConfigurationBuilder<XMLConfiguration> builder =
>     new 
> FileBasedConfigurationBuilder<XMLConfiguration>(XMLConfiguration.class)
>     .configure(params.xml()
>         .setFileName("windowconfig.xml"));
> XMLConfiguration config = builder.getConfiguration();
> BeanDeclaration decl = new XMLBeanDeclaration(config, "gui.windowManager");
> WindowManager wm = (WindowManager) BeanHelper.INSTANCE.createBean(decl);
> 
> It seems that in order to create a bean you must create a BeanDeclaration,
> which seems to require knowledge of the implementation of the
> configuration.
> 
> What if you had a method on ImmutableHierarchicalConfiguration (or
> ImmutableConfiguration) such as:
> 
>    BeanDeclaration getBeanDeclaration(String key)
> 
> Then use would not be coupled to an implementation.
> 
>     ImmutableHierarchicalConfiguration config = ... Built any way you want
> ...
>     BeanDeclaration decl = config.getBeanDeclaration("gui.windowManager");
>     WindowManager wm = (WindowManager)
> BeanHelper.INSTANCE.createBean(decl);

This is a valid point.

Historically, bean declarations were only used internally to construct
combined configurations and their helper objects. This functionality
seemed to be useful in a more broader context, so the classes were
exposed to the public. However, there is only a single implementation
suitable for hierarchical configurations. Therefore, adding a
getBeanDeclaration() method to ImmutableConfiguration would require that
corresponding implementations for other types of configurations would be
created.

Nevertheless, such a method could be added to the
ImmutableHierarchicalConfiguration interface. Alternatively, a separate
interface - maybe BeanCreationSupport? - could be added which defines
only this method. This would be more flexible as it could be implemented
by various configuration classes independent on their supported
Configuration interface.

WDYT?
Oliver

> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
> 

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

Reply via email to