deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r842559 - in /websites/staging/deltaspike/trunk/content: ./ deltaspike/core.html
Date Sat, 15 Dec 2012 22:12:17 GMT
Author: buildbot
Date: Sat Dec 15 22:12:16 2012
New Revision: 842559

Staging update by buildbot for deltaspike

    websites/staging/deltaspike/trunk/content/   (props changed)

Propchange: websites/staging/deltaspike/trunk/content/
--- cms:source-revision (original)
+++ cms:source-revision Sat Dec 15 22:12:16 2012
@@ -1 +1 @@

Modified: websites/staging/deltaspike/trunk/content/deltaspike/core.html
--- websites/staging/deltaspike/trunk/content/deltaspike/core.html (original)
+++ websites/staging/deltaspike/trunk/content/deltaspike/core.html Sat Dec 15 22:12:16 2012
@@ -313,10 +313,43 @@ For such cases a custom ExpressionInterp
 <h2 id="type-safe-config">Type-safe config</h2>
+<h3 id="configresolver">ConfigResolver</h3>
+<p>In some cases low-level configs are needed e.g. during the bootstrapping process
of the CDI container. (Currently it's e.g. used for configuring the value of the current project-stage,
configured values which can be used in the expressions for <code>@Exclude</code>,...)
Usually it isn't used by users directly, but DeltaSpike needs such a low-level approach for
several features. Therefore it's possible to use a so called <code>ConfigResolver</code>
which resolves and caches <code>ConfigSource</code>s per application.
+The method <code>ConfigResolver#getPropertyValue</code> allows to provide a string
based key and returns the configured value as <code>String</code> or <code>null</code>
if no value has been found (<code>#getAllPropertyValues</code> has a similar contract
but it returns a list which might be empty if there are no configured values for the given
key). Optionally it's possible to provide a default value which gets retured instead of <code>null</code>.</p>
+<p>Simple lookup in the low-level config:</p>
+<div class="codehilite"><pre><span class="n">ConfigResolver</span><span
class="o">.</span><span class="n">getPropertyValue</span><span class="p">(</span><span
class="s">&quot;myKey&quot;</span><span class="p">);</span>
 <h3 id="configproperty">@ConfigProperty</h3>
 <h3 id="propertyfileconfig">PropertyFileConfig</h3>
-<h3 id="configresolver">ConfigResolver</h3>
+<h3 id="configsource">ConfigSource</h3>
+<p>A <code>ConfigResolver</code> uses all configured implementations of
<code>ConfigSource</code> to lookup the property in question.</p>
+<p>Per default there are implementations for the following config sources (listed in
the lookup order):</p>
+<li>System properties</li>
+<li>Environment properties</li>
+<li>JNDI values</li>
+<li>Properties file values (</li>
+<p><strong>It's possible to change this order and to add custom config sources.</strong></p>
+<p><strong>Note:</strong> Important Hints esp. for custom implementations:
+  - The config-source with the highest ordinal gets used first.
+  - If a custom implementation should be invoked <em>before</em> the default
implementations, use an ordinal-value &gt; 400
+  - If a custom implementation should be invoked <em>after</em> the default implementations,
use an ordinal-value &lt; 100</p>
+<h3 id="reordering-of-the-default-order-of-config-sources">Reordering of the default
order of Config-Sources</h3>
+<p>To change the lookup order, you have to configure the ordinal in the corresponding
config source (e.g. to change the config ordinal of the config source for system properties,
you have to set the system property with the ordinal key 'deltaspike_ordinal' and the new
+<p>Example with <code>/META-INF/</code>: If
the properties file/s should be used <strong>before</strong> the other implementations,
you have to configure an ordinal &gt; 400. That means, you have to add e.g. <code>deltaspike_ordinal=401</code>.</p>
+In case of <strong>property files</strong> which are supported by default (<code>/META-INF/</code>)
every file is handled as independent config-source, but all of them have ordinal 400 by default
(and can be reordered in a fine-grained manner).</p>
+<h3 id="custom-config-sources">Custom Config-Sources</h3>
+<p>To add a custom config-source, you have to implement the interface <code>ConfigSourceProvider</code>
(and <code>ConfigSource</code>) and activate the implementation of <code>ConfigSourceProvider</code>
with the std. SPI mechanism provided by Java via the <code>ServiceLoader</code>
(that means you have to create <code>/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSourceProvider</code>
which contains the fully qualified class name of the custom implementation/s).</p>
+<p>If you have a simple standalone <code>ConfigSource</code> you can also
register it directly by creating a file <code>/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSource</code>
which contains the fully qualified class name of your <code>ConfigSource</code>.
+Please note that a single <code>ConfigSource</code> should be either registered
directly or via a <code>ConfigSourceProvider</code>, but never both ways. </p>
+<p><strong>Important Hint:</strong>
+Have a look at the abstract base-implementation of <code>ConfigSource</code>
DeltaSpike is using internally, if a custom implementation should load the ordinal value from
the config-source like the default implementations provided by DeltaSpike do.</p>
 <h2 id="type-safe-view-config">Type-safe View-Config</h2>
 <p>TODO (Overview)</p>
 <h2 id="literals">Literals</h2>
@@ -339,7 +372,7 @@ For such cases a custom ExpressionInterp
 <h2 id="config">Config</h2>
 <h3 id="configsourceprovider">ConfigSourceProvider</h3>
-<h3 id="configsource">ConfigSource</h3>
+<h3 id="configsource_1">ConfigSource</h3>
 <h2 id="exception-control_1">Exception Control</h2>
 <h3 id="introspectiveexceptionevent">IntrospectiveExceptionEvent</h3>

View raw message