eclipse / ConfigJSR

JSR382
Apache License 2.0
30 stars 22 forks source link

Change support with more control for Config #95

Closed tomas-langer closed 6 years ago

tomas-langer commented 6 years ago

Current approach does not give Config implementation enough information to optimize access to property values - these can never be cached, as each config source may be unscannable and may not inform about changes. To support this, we should be able to obtain these attributes of a config source:

  1. Mutability: can this config source change its values?
  2. Scannability: can this config source list the keys (and maybe values) provided by it?
  3. Change support: can this config source consistently notify of changed keys/values?
tomas-langer commented 6 years ago

In the pull request, the problems are solved as follows:

  1. Mutability: you can return ChangeSupport.IMMUTABLE when config sets the change callback
  2. Scannability: methods getProperties() and getPropertyNames() now return Optional. If empty, this source is not scannable
  3. Change support: you can return either of ConfigSource.ChangeSupport enum values when config sets callback to inform config about your source behavior. The options are:
    1. SUPPORTED: This config source is mutable and supports callback
    2. UNSUPPORTED: This config source is mutable and does not support callback
    3. IMMUTABLE: This config source is immutable, changes never happen