deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject deltaspike git commit: add documentation about how to work with dynamically changing config
Date Wed, 18 May 2016 17:12:12 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 403c0b79b -> 172983ff1


add documentation about how to work with dynamically changing config


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/172983ff
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/172983ff
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/172983ff

Branch: refs/heads/master
Commit: 172983ff14c5ec2182d438640fd0a9f6f1bf36fe
Parents: 403c0b7
Author: Mark Struberg <struberg@apache.org>
Authored: Wed May 18 19:11:07 2016 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Wed May 18 19:11:55 2016 +0200

----------------------------------------------------------------------
 .../src/main/asciidoc/configuration.adoc        | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/172983ff/documentation/src/main/asciidoc/configuration.adoc
----------------------------------------------------------------------
diff --git a/documentation/src/main/asciidoc/configuration.adoc b/documentation/src/main/asciidoc/configuration.adoc
index d59b85d..89f199c 100644
--- a/documentation/src/main/asciidoc/configuration.adoc
+++ b/documentation/src/main/asciidoc/configuration.adoc
@@ -223,6 +223,28 @@ public class CustomDateConverter implements ConfigResolver.Converter<Date>
{
 }
 ------------------------------------------------------------------------------------------
 
+==== Dynamic Reloading
+
+The TypedResolver can also be used to efficiently cache configured values.
+That way you can pick up configuration which might get changed during runtime on the fly.
+E.g. if you have a ConfigSource which picks up the values from a database table.
+Instead of resolving the configured value at the beginning you simply invoke `.getValue()`
on your TypedResolver each time you need the value.
+
+.Working with dynamically changing values
+[source,java]
+-----------------------------------------------------------------
+private ConfigResolver.TypedResolver<String> urlConfig
+    = ConfigResolver.resolve("myapp.some.remote.rest.url")
+                    .logChanges(true)
+                    .cacheFor(TimeUnit.MINUTES, 5);
+
+...
+
+connecTo( urlConfig.getValue() );
+-----------------------------------------------------------------
+The sample above will log any value changes in the configuration (`logChanges(true)`) and
internally cache the configured value for 5 minutes (`cacheFor(TimeUnit.MINUTES, 5)`).
+Only after that time the configured value will get evaluate again.
+
 === Injection of configured values into beans using @ConfigProperty
 
 DeltaSpike provides a way to inject configured values into your code via the qualifier `@ConfigProperty`.


Mime
View raw message