commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CONFIGURATION-519) Provide a builder API for creating configuration objects
Date Sat, 24 May 2014 13:50:01 GMT

     [ https://issues.apache.org/jira/browse/CONFIGURATION-519?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Oliver Heger resolved CONFIGURATION-519.
----------------------------------------

    Resolution: Fixed

This feature has been implemented and also documented in the user's guide.

> Provide a builder API for creating configuration objects
> --------------------------------------------------------
>
>                 Key: CONFIGURATION-519
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-519
>             Project: Commons Configuration
>          Issue Type: Improvement
>    Affects Versions: 1.9
>            Reporter: Oliver Heger
>             Fix For: 2.0
>
>
> Currently, concrete {{Configuration}} implementations are directly instantiated using
their constructors. How this works in detail depends on a concrete class: some constructors
accept initializazion parameters, in other cases only a default constructor is available,
and further properties have to be set using set methods.
> File-based configurations allow a client to pass in the file to be loaded in various
forms (URL, File, file name, etc.). The data is then directly loaded by the constructor which
is problematic for various reasons:
> * The constructors execute complex operations.
> * Loading of the configuration file can fail which will then throw an exception.
> * The constructors invoke non-final methods for loading data. (_Note_: This is not only
a theoretical problem but has indeed caused trouble in practice, e.g. when trying to set a
default encoding for {{PropertiesConfiguration}}.)
> * Some properties only take effect when set before loading a configuration file. So when
these properties are needed, it is not possible to use a constructor which already performs
the load operation. This API is confusing.
> As an alternative, a builder-like API can be provided: Client code creates a builder
object and sets initialization properties for the {{Configuration}} object to be constructed
using a convenient (fluent) API. Then a fully initialized {{Configuration}} object can be
obtained from the builder. The required steps for creating a configuration would be always
the same, no matter which concrete {{Configuration}} subclass is actually created.
> In addition, builders could play an important role when it comes to improving the current
reloading mechanisms. For this a separate ticket will be opened.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message