Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-243

Improve handling of optional configurations in DefaultConfigurationBuilder

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:
      None

      Description

      So far a configuration declared as optional in the configuration definition file won't be added to the resulting combined configuration when its initialization causes an error. There are use cases where this behavior is not appropriate:

      Consider as an example an application that needs to store user specific settings in a user configuration file (e.g. stored in the user's home directory). The application's configuration definition file would include this user configuration and declare it as optional. When a user starts this application for the first time the user configuration does not exist; so its creation will cause an error and it won't be added to the combined configuration. Now every time the application wants to access the user configuration it has to check whether it exists and manually create it if necessary. Here it would be much easier if an empty configuration of the correct type was added to the combined configuration.

      This behavior could be controlled by an additional reserved attribute config-forceCreate of a configuration declaration.

      By the way: The nested class ConfigurationDeclaration of DefaultConfigurationBuilder should be public. This makes the implementation of custom configuration providers easier.

        Attachments

          Activity

            People

            • Assignee:
              oheger Oliver Heger
              Reporter:
              oheger Oliver Heger
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: