From e88605a002ea331b3ee947d53694a7eaf8d99596 Mon Sep 17 00:00:00 2001 From: Emily Jiang Date: Fri, 22 Nov 2019 15:38:44 +0000 Subject: [PATCH] #457 add a section to make dynamic config source more visible Signed-off-by: Emily Jiang --- spec/src/main/asciidoc/configsources.asciidoc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/src/main/asciidoc/configsources.asciidoc b/spec/src/main/asciidoc/configsources.asciidoc index 82465c2f..0ef2b1fa 100644 --- a/spec/src/main/asciidoc/configsources.asciidoc +++ b/spec/src/main/asciidoc/configsources.asciidoc @@ -147,6 +147,17 @@ public class ExampleYamlConfigSourceProvider Please note that a single `ConfigSource` should be either registered directly or via a `ConfigSourceProvider`, but never both ways. +=== Dynamic ConfigSource +A dynamic ConfigSource is a `ConfigSource` where its content can be updated, such as updating a property name or value or adding or deleting config properties +from it. For the property lookup, the method `config.getValue()` or `config.getOptionalValue()` retrieves the up-to-date value. +Alternatively, for the injection style, the following lookup should be used to retrieve the up-to-date value. +[source, text] +---- + @Inject + @ConfigProperty(name="myprj.some.dynamic.timeout", defaultValue="100") + private javax.inject.Provider timeout; +---- + === Cleaning up a ConfigSource If a `ConfigSource` implements the `java.lang.AutoCloseable` interface then the `close()` method will be called when the underlying `Config` is being released.