deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1744440 - /deltaspike/site/trunk/content/documentation/configuration.html
Date Wed, 18 May 2016 17:21:57 GMT
Author: struberg
Date: Wed May 18 17:21:57 2016
New Revision: 1744440

URL: http://svn.apache.org/viewvc?rev=1744440&view=rev
Log:
Site checkin for project Apache DeltaSpike Documentation

Modified:
    deltaspike/site/trunk/content/documentation/configuration.html

Modified: deltaspike/site/trunk/content/documentation/configuration.html
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/documentation/configuration.html?rev=1744440&r1=1744439&r2=1744440&view=diff
==============================================================================
--- deltaspike/site/trunk/content/documentation/configuration.html (original)
+++ deltaspike/site/trunk/content/documentation/configuration.html Wed May 18 17:21:57 2016
@@ -592,6 +592,32 @@ Custom types can be supported by providi
 </div>
 </div>
 </div>
+<div class="sect3">
+<h4 id="_dynamic_reloading">Dynamic Reloading</h4>
+<div class="paragraph">
+<p>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 <code>.getValue()</code>
on your TypedResolver each time you need the value.</p>
+</div>
+<div class="listingblock">
+<div class="title">Working with dynamically changing values</div>
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">private</span>
ConfigResolver.TypedResolver&lt;<span class="predefined-type">String</span>&gt;
urlConfig
+    = ConfigResolver.resolve(<span class="string"><span class="delimiter">&quot;</span><span
class="content">myapp.some.remote.rest.url</span><span class="delimiter">&quot;</span></span>)
+                    .logChanges(<span class="predefined-constant">true</span>)
+                    .cacheFor(<span class="predefined-type">TimeUnit</span>.MINUTES,
<span class="integer">5</span>);
+
+...
+
+connecTo( urlConfig.getValue() );</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The sample above will log any value changes in the configuration (<code>logChanges(true)</code>)
and internally cache the configured value for 5 minutes (<code>cacheFor(TimeUnit.MINUTES,
5)</code>).
+Only after that time the configured value will get evaluate again.</p>
+</div>
+</div>
 </div>
 <div class="sect2">
 <h3 id="_injection_of_configured_values_into_beans_using_configproperty">Injection
of configured values into beans using @ConfigProperty</h3>
@@ -977,6 +1003,7 @@ log.</p>
 <li><a href="#_typedresolver_api">TypedResolver API</a>
 <ul class="sectlevel3">
 <li><a href="#_supported_types">Supported types</a></li>
+<li><a href="#_dynamic_reloading">Dynamic Reloading</a></li>
 </ul>
 </li>
 <li><a href="#_injection_of_configured_values_into_beans_using_configproperty">Injection
of configured values into beans using @ConfigProperty</a>



Mime
View raw message