deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r925846 [2/10] - in /websites/staging/deltaspike/trunk/content: ./ documentation/staging/
Date Wed, 15 Oct 2014 13:19:38 GMT
Added: websites/staging/deltaspike/trunk/content/documentation/staging/configuration.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/documentation/staging/configuration.html (added)
+++ websites/staging/deltaspike/trunk/content/documentation/staging/configuration.html Wed Oct 15 13:19:37 2014
@@ -0,0 +1,597 @@
+<!DOCTYPE html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="deltaspike-generate-pages">
+<meta name="author" content="chm">
+
+<title>DeltaSpike Configuration Mechanism</title>
+
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file to you under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License.  You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and limitations under the License. -->
+
+<!-- Styles -->
+
+<link href="https://deltaspike.apache.org/resources/css/bootstrap.css" rel="stylesheet">
+<link href="https://deltaspike.apache.org/resources/css/bootstrap-responsive.css" rel="stylesheet">
+
+<style type="text/css">
+/* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
+/*pre.CodeRay {background-color:#f7f7f8;}*/
+.CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
+.CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
+.CodeRay .line-numbers strong{font-weight: normal}
+table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
+table.CodeRay td{vertical-align: top}
+table.CodeRay td.line-numbers{text-align:right}
+table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
+table.CodeRay td.code{padding:0 0 0 .5em}
+table.CodeRay td.code>pre{padding:0}
+.CodeRay .debug{color:#fff !important;background:#000080 !important}
+.CodeRay .annotation{color:#007}
+.CodeRay .attribute-name{color:#000080}
+.CodeRay .attribute-value{color:#700}
+.CodeRay .binary{color:#509}
+.CodeRay .comment{color:#998;font-style:italic}
+.CodeRay .char{color:#04d}
+.CodeRay .char .content{color:#04d}
+.CodeRay .char .delimiter{color:#039}
+.CodeRay .class{color:#458;font-weight:bold}
+.CodeRay .complex{color:#a08}
+.CodeRay .constant,.CodeRay .predefined-constant{color:#008080}
+.CodeRay .color{color:#099}
+.CodeRay .class-variable{color:#369}
+.CodeRay .decorator{color:#b0b}
+.CodeRay .definition{color:#099}
+.CodeRay .delimiter{color:#000}
+.CodeRay .doc{color:#970}
+.CodeRay .doctype{color:#34b}
+.CodeRay .doc-string{color:#d42}
+.CodeRay .escape{color:#666}
+.CodeRay .entity{color:#800}
+.CodeRay .error{color:#808}
+.CodeRay .exception{color:inherit}
+.CodeRay .filename{color:#099}
+.CodeRay .function{color:#900;font-weight:bold}
+.CodeRay .global-variable{color:#008080}
+.CodeRay .hex{color:#058}
+.CodeRay .integer,.CodeRay .float{color:#099}
+.CodeRay .include{color:#555}
+.CodeRay .inline{color:#00}
+.CodeRay .inline .inline{background:#ccc}
+.CodeRay .inline .inline .inline{background:#bbb}
+.CodeRay .inline .inline-delimiter{color:#d14}
+.CodeRay .inline-delimiter{color:#d14}
+.CodeRay .important{color:#555;font-weight:bold}
+.CodeRay .interpreted{color:#b2b}
+.CodeRay .instance-variable{color:#008080}
+.CodeRay .label{color:#970}
+.CodeRay .local-variable{color:#963}
+.CodeRay .octal{color:#40e}
+.CodeRay .predefined{color:#369}
+.CodeRay .preprocessor{color:#579}
+.CodeRay .pseudo-class{color:#555}
+.CodeRay .directive{font-weight:bold}
+.CodeRay .type{font-weight:bold}
+.CodeRay .predefined-type{color:inherit}
+.CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold}
+.CodeRay .key{color:#808}
+.CodeRay .key .delimiter{color:#606}
+.CodeRay .key .char{color:#80f}
+.CodeRay .value{color:#088}
+.CodeRay .regexp .delimiter{color:#808}
+.CodeRay .regexp .content{color:#808}
+.CodeRay .regexp .modifier{color:#808}
+.CodeRay .regexp .char{color:#d14}
+.CodeRay .regexp .function{color:#404;font-weight:bold}
+.CodeRay .string{color:#d20}
+.CodeRay .string .string .string{background:#ffd0d0}
+.CodeRay .string .content{color:#d14}
+.CodeRay .string .char{color:#d14}
+.CodeRay .string .delimiter{color:#d14}
+.CodeRay .shell{color:#d14}
+.CodeRay .shell .delimiter{color:#d14}
+.CodeRay .symbol{color:#990073}
+.CodeRay .symbol .content{color:#a60}
+.CodeRay .symbol .delimiter{color:#630}
+.CodeRay .tag{color:#008080}
+.CodeRay .tag-special{color:#d70}
+.CodeRay .variable{color:#036}
+.CodeRay .insert{background:#afa}
+.CodeRay .delete{background:#faa}
+.CodeRay .change{color:#aaf;background:#007}
+.CodeRay .head{color:#f8f;background:#505}
+.CodeRay .insert .insert{color:#080}
+.CodeRay .delete .delete{color:#800}
+.CodeRay .change .change{color:#66f}
+.CodeRay .head .head{color:#f4f}
+body {
+	padding-top: 60px;
+	padding-bottom: 40px;
+}
+</style>
+<script type="text/javascript">
+
+	  var _gaq = _gaq || [];
+	  _gaq.push(['_setAccount', 'UA-36103647-1']);
+	  _gaq.push(['_trackPageview']);
+	
+	  (function() {
+		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+	  })();
+	
+	</script>
+</head>
+
+<body>
+
+	<div class="navbar navbar-fixed-top">
+		<div class="navbar-inner">
+			<div class="container">
+				<a class="btn btn-navbar" data-toggle="collapse"
+					data-target=".nav-collapse"> <span class="icon-bar"></span> <span
+					class="icon-bar"></span> <span class="icon-bar"></span>
+				</a> <a class="brand logocolor"
+					href="http://deltaspike.apache.org/index.html">Apache
+					DeltaSpike</a>
+				<div class="nav-collapse">
+					<ul class="nav">
+						<li class="active"><a
+							href="http://deltaspike.apache.org/index.html">Home</a></li>
+						<li><a href="http://deltaspike.apache.org/documentation">Documentation</a></li>
+						<li><a href="http://deltaspike.apache.org/source.html">Source</a></li>
+						<li><a href="http://deltaspike.apache.org/download.html">Download</a></li>
+						<li><a href="http://deltaspike.apache.org/community.html">Community</a></li>
+						<!-- <li><a href="./support.html">Support</a></li>  -->
+						<li><a href="http://deltaspike.apache.org/news.html">News</a></li>
+						<li><a
+							href="http://deltaspike.apache.org/migration-guide.html">Migration</a></li>
+					</ul>
+				</div>
+				<!--/.nav-collapse -->
+				<form id="search-form" action="http://www.google.com/search"
+					method="get" class="navbar-search pull-right">
+					<input value="deltaspike.apache.org" name="sitesearch"
+						type="hidden"> <input class="search-query" name="q"
+						id="query" type="text">
+				</form>
+			</div>
+		</div>
+	</div>
+
+	<div class="container">
+		<div class="row">
+			<div class="span12">
+				<div class="page-title">
+			    <h1>DeltaSpike Configuration Mechanism</h1>
+                </div>
+
+				<div id="toc" class="toc">
+       	 		<ul class="sectlevel1">
+<li><a href="#_configuration_basics">Configuration Basics</a>
+<ul class="sectlevel2">
+<li><a href="#_benefits_for_production">Benefits for Production</a></li>
+<li><a href="#_drop_in_configuration">Drop-In Configuration</a></li>
+<li><a href="#_cdi_extension_configuration">CDI-Extension Configuration</a></li>
+<li><a href="#_userland_configuration">Userland Configuration</a></li>
+</ul>
+</li>
+<li><a href="#_configresolver">ConfigResolver</a>
+<ul class="sectlevel2">
+<li><a href="#_getpropertyvalue">getPropertyValue()</a></li>
+<li><a href="#_getprojectstageawarepropertyvalue">getProjectStageAwarePropertyValue()</a></li>
+<li><a href="#_getpropertyawarepropertyvalue">getPropertyAwarePropertyValue()</a></li>
+<li><a href="#_handling_of_default_values">handling of default values</a></li>
+</ul>
+</li>
+<li><a href="#_configsource">ConfigSource</a>
+<ul class="sectlevel2">
+<li><a href="#_configsources_provided_by_default">ConfigSources provided by default</a></li>
+<li><a href="#_reordering_of_the_default_order_of_config_sources">Reordering of the default order of Config-Sources</a></li>
+<li><a href="#_custom_config_sources">Custom Config-Sources</a>
+<ul class="sectlevel3">
+<li><a href="#_propertyfileconfig">PropertyFileConfig</a></li>
+</ul>
+</li>
+</ul>
+</li>
+<li><a href="#_type_safe_configuration">Type-safe configuration</a></li>
+</ul>
+       	 		<hr>	
+       	 		
+				<div class="sect1">
+<h2 id="_configuration_basics">Configuration Basics</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The goal of the DeltaSpike configuration mechanism is to make it
+obsolete to touch released binaries for changing the configuration of
+your project. All values which are needed in your code (but should not
+be hardcoded as static final constants) can be maintained via
+DeltaSpikes own configuration mechanism in a very flexible and powerful
+way.</p>
+</div>
+<div class="sect2">
+<h3 id="_benefits_for_production">Benefits for Production</h3>
+<div class="paragraph">
+<p>Once a binary like a WAR file or an EAR got created and tested, it must
+<em>not</em> get changed anymore. The exact same binary which got created by
+the release manager will get moved to the Test system, then further
+propagated to the Staging environment and finally (if all people are
+happy with it) will get moved to the Production system. And all this
+without any changes on the binary itself!</p>
+</div>
+<div class="paragraph">
+<p>The Apache DeltaSpike configuration system makes this possible by
+providing a default configuration inside the binary and allowing to
+amend this configuration (e.g. database credentials, some URLs from
+remote REST or SOAP endpoints, etc) from outside like environment
+settings, JNDI or the current <a href="projectstage.html">ProjectStage</a>.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_drop_in_configuration">Drop-In Configuration</h3>
+<div class="paragraph">
+<p>This mechanism also allows for dynamic configuration in case of a JAR
+drop-in. By adding some JAR to the classpath, all it&#8217;s contained
+configuration will get picked up and considered in the property value
+evaluation. You could also use this mechanism to switch implementations
+of some SPI (Service Provider Interface) in your own code.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_cdi_extension_configuration">CDI-Extension Configuration</h3>
+<div class="paragraph">
+<p>In some cases low-level configs are needed e.g. during the bootstrapping
+process of the CDI container.</p>
+</div>
+<div class="paragraph">
+<p>The good news: our DeltaSpike configuration mechanism does not rely on
+any other EE mechanism to be booted. Which means it can perfectly get
+used to even configure those parts itself. Since the mechanism doesn&#8217;t
+rely on CDI it can for example be used to configure CDI-Extensions.</p>
+</div>
+<div class="paragraph">
+<p>Currently this is e.g. used to configure the value of the current <a href="projectstage.html">ProjectStage</a>, configured values which can be
+used in the expressions for <code>@Exclude</code>, 'Deactivatable', etc. DeltaSpike
+needs such a low-level approach for several features internally, but
+users can utilize it for their own needs as well. This is done by using
+the <code>ConfigResolver</code> which resolves and caches `ConfigSource`s per
+application.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_userland_configuration">Userland Configuration</h3>
+<div class="paragraph">
+<p>DeltaSpike also provides a mechanism to inject those configured values
+using the <code>@ConfigProperty</code> CDI Qualifier.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configresolver">ConfigResolver</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The <code>ConfigResolver</code> is the central point to pick up configured values
+in DeltaSpike.</p>
+</div>
+<div class="sect2">
+<h3 id="_getpropertyvalue">getPropertyValue()</h3>
+<div class="paragraph">
+<p>The method <code>ConfigResolver#getPropertyValue(String key)</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.</p>
+</div>
+<div class="paragraph">
+<p><code>ConfigResolver#getAllPropertyValues(String key)</code> has a similar contract
+but it returns a list which might be empty if there are no configured
+values for the given key.</p>
+</div>
+<div class="paragraph">
+<p>This is a code excerpt about how to do a simple lookup in the deltaspike
+configuration:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="predefined-type">String</span> dbUserName = ConfigResolver.getPropertyValue(<span class="string"><span class="delimiter">&quot;</span><span class="content">databaseconfig.username</span><span class="delimiter">&quot;</span></span>);</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_getprojectstageawarepropertyvalue">getProjectStageAwarePropertyValue()</h3>
+<div class="paragraph">
+<p>The method
+<code>ConfigResolver#getProjectStageAwarePropertyValue(String key)</code> utilizes
+the <a href="projectstage.html">DeltaSpike ProjectStage</a> mechanism to allow
+configured values to depend on the current <code>ProjectStage</code> of the system
+we run on.</p>
+</div>
+<div class="paragraph">
+<p>This is done by first looking up the ProjectStage (this internally
+happens with the DeltaSpike ConfigResolver as well) and then go down the
+following lookup chain until we found a configured value.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>key + '.' + projectStage , e.g. "databaseconfig.username.Production"</p>
+</li>
+<li>
+<p>key alone , e.g. "databaseconfig.username"</p>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_getpropertyawarepropertyvalue">getPropertyAwarePropertyValue()</h3>
+<div class="paragraph">
+<p>The method
+<code>ConfigResolver#getProjectStageAwarePropertyValue(String key, String property)</code>
+first looks up the configured value of the given property and uses this
+value to determine the final lookup path. All those lookups take the
+<a href="projectstage.html">DeltaSpike ProjectStage</a> mechanism into account.</p>
+</div>
+<div class="paragraph">
+<p>Given we have the following code in our program:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="predefined-type">String</span> dbUserName = ConfigResolver.getPropertyAwarePropertyValue(<span class="string"><span class="delimiter">&quot;</span><span class="content">databaseconfig.username</span><span class="delimiter">&quot;</span></span>, <span class="string"><span class="delimiter">&quot;</span><span class="content">dbvendor</span><span class="delimiter">&quot;</span></span>);</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This will end up in the following lookup sequences. First we need to
+resolve the value of the property:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>propertyValue = property + '.' + projectStage, e.g. "dbvendor.Production"</p>
+</li>
+<li>
+<p>if nothing found: propertyValue = property, e.g. "dbvendor"</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Let&#8217;s assume we found the value 'mysql' for our dbvendor. In this case
+the following lookup chain is used until a value got found:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>key + '.' + property + projectstage, e.g. "databaseconfig.username.mysql.Production"</p>
+</li>
+<li>
+<p>key + '.' + property, e.g. "databaseconfig.username.mysql"</p>
+</li>
+<li>
+<p>key + '.' + projectstage, e.g. "databaseconfig.username.Production"</p>
+</li>
+<li>
+<p>key, e.g. "databaseconfig.username"</p>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_handling_of_default_values">handling of default values</h3>
+<div class="paragraph">
+<p>There is a 2nd variant of all those methods where it is possible to
+provide a default value which gets returned instead of <code>null</code> or if the
+final result is an empty String.</p>
+</div>
+<div class="paragraph">
+<p><strong>Performance Hint:</strong></p>
+</div>
+<div class="paragraph">
+<p>The only <code>ConfigResolver</code> operation which is cached is the determination
+of the <code>ConfigSources</code>. The various getPropertyValue operations are not
+cached in the ConfigResolver but might be cached in the ConfigSources.
+This makes the overall calculation a bit slower, but allows for values
+to change dynamically if someone likes to e.g. implement a
+<code>JmxConfigSource</code> (not yet part of DeltaSpike, but easily
+implementable).</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configsource">ConfigSource</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>A <code>ConfigSource</code> is exactly what it&#8217;s name says: a source for configured
+values. The <code>ConfigResolver</code> uses all configured implementations of
+<code>ConfigSource</code> to lookup the property in question.</p>
+</div>
+<div class="paragraph">
+<p>Each 'ConfigSource' has a specified 'ordinal' which can be configured
+using the key <code>deltaspike_ordinal</code>. This ordinal get&#8217;s used to determine
+the importance of the values taken from the very ConfigSource. A higher
+ordinal means that the values taken from this ConfigSource will override
+values from less important ConfigSources. This is the trick which allows
+to amend configuration from outside a binary - given those outside
+ConfigSources have a higher <code>deltaspike_ordinal</code> than the ones who
+pickup the values from within the release binaries.</p>
+</div>
+<div class="sect2">
+<h3 id="_configsources_provided_by_default">ConfigSources provided by default</h3>
+<div class="paragraph">
+<p>Per default there are implementations for the following config sources
+(listed in the lookup order):</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>System properties (deltaspike_ordinal = 400)</p>
+</li>
+<li>
+<p>Environment properties (deltaspike_ordinal = 300)</p>
+</li>
+<li>
+<p>JNDI values (deltaspike_ordinal = 200, the base name is "java:comp/env/deltaspike/")</p>
+</li>
+<li>
+<p>Properties file values (apache-deltaspike.properties) (deltaspike_ordinal = 100, default filename is "META-INF/apache-deltaspike.properties")</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p><strong>It&#8217;s possible to change this order and to add custom config sources.</strong></p>
+</div>
+<div class="paragraph">
+<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
+- The <code>ConfigResolver</code> performs no caching. If your custom ConfigSource
+operation is expensive, then you might think about introducing some
+caching.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_reordering_of_the_default_order_of_config_sources">Reordering of the default order of Config-Sources</h3>
+<div class="paragraph">
+<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 value).</p>
+</div>
+<div class="paragraph">
+<p>Example with <code>/META-INF/apache-deltaspike.properties</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>
+</div>
+<div class="paragraph">
+<p>Each single property file is treated as own <code>ConfigSource</code> and thus can
+have different <code>deltaspike_ordinal</code> values!</p>
+</div>
+<div class="paragraph">
+<p><strong>Hint:</strong></p>
+</div>
+<div class="paragraph">
+<p>In case of <strong>property files</strong> which are supported by default
+(<code>/META-INF/apache-deltaspike.properties</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>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_custom_config_sources">Custom Config-Sources</h3>
+<div class="paragraph">
+<p>ConfigSources are picked up using the `java.util.ServiceLoader'
+mechanism.</p>
+</div>
+<div class="paragraph">
+<p>To add a custom config-source, you have to implement the interface
+<code>ConfigSource</code> and register your implementation in a file
+<code>/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSource</code>
+by writing the fully qualified class name of the custom implementation/s
+into it.</p>
+</div>
+<div class="paragraph">
+<p>If you need dynamic ConfigSources you can also register a
+<code>ConfigSourceProvider</code> in a similar way. This is useful if you like to
+dynamically pick up multiple ConfigSources of the same kind. E.g. if you
+like to pick up all <code>myproject.properties</code> files from all the JARs in
+your classpath.</p>
+</div>
+<div class="paragraph">
+<p>Please note that a single <code>ConfigSource</code> should be either registered
+directly or via a <code>ConfigSourceProvider</code>, but never both ways.</p>
+</div>
+<div class="paragraph">
+<p><strong>Important Hint:</strong></p>
+</div>
+<div class="paragraph">
+<p>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>
+</div>
+<div class="sect3">
+<h4 id="_propertyfileconfig">PropertyFileConfig</h4>
+<div class="paragraph">
+<p>For registering all your own property files of a certain name in your
+classpath to get picked up as <code>ConfigSource`s you can also provide a
+class which implements the `PropertyFileConfig</code> interface.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">MyCustomPropertyFileConfig</span> <span class="directive">implements</span> PropertyFileConfig
+{
+    <span class="annotation">@Override</span>
+    <span class="directive">public</span> <span class="predefined-type">String</span> getPropertyFileName()
+    {
+        <span class="keyword">return</span> <span class="string"><span class="delimiter">&quot;</span><span class="content">myconfig.properties</span><span class="delimiter">&quot;</span></span>;
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><em>Note: If you are using WildFly with EAR packaging and with
+ear-subdeployments-isolated=true, then your EAR should have a deployment
+dependency to the module that contains the property file.</em></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;jboss-deployment-structure&gt;</span>
+    <span class="tag">&lt;ear-subdeployments-isolated&gt;</span>true<span class="tag">&lt;/ear-subdeployments-isolated&gt;</span>
+      <span class="tag">&lt;deployment&gt;</span>
+            <span class="tag">&lt;dependencies&gt;</span>
+            <span class="comment">&lt;!-- This module contains the custom PropertyFileConfig and the property file --&gt;</span>
+                  <span class="tag">&lt;module</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">deployment.yourproject.ear.yoursubmodule.jar</span><span class="delimiter">&quot;</span></span>  <span class="attribute-name">meta-inf</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">import</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span>
+            <span class="tag">&lt;/dependencies&gt;</span>
+     <span class="tag">&lt;/deployment&gt;</span>
+<span class="tag">&lt;/jboss-deployment-structure&gt;</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_type_safe_configuration">Type-safe configuration</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>DeltaSpike provides a way to directly inject configured values into your
+code via the qualifier <code>@ConfigProperty</code>.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>@ApplicationScoped
+public class SomeRandomService
+{
+    @Inject
+    @ConfigProperty(name = "endpoint.poll.interval")
+    private Integer pollInterval;
+
+    @Inject
+    @ConfigProperty(name = "endpoint.poll.servername")
+    private String pollUrl;
+
+    ...
+ }</pre>
+</div>
+</div>
+</div>
+</div>
+			</div>
+
+			<hr>
+
+			<footer>
+				<p>Copyright © 2011-2014 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.</p>
+				<p>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
+			</footer>
+
+		</div>
+		<!-- /.container -->
+
+</body>
+</html>
\ No newline at end of file

Added: websites/staging/deltaspike/trunk/content/documentation/staging/configure.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/documentation/staging/configure.html (added)
+++ websites/staging/deltaspike/trunk/content/documentation/staging/configure.html Wed Oct 15 13:19:37 2014
@@ -0,0 +1,353 @@
+<!DOCTYPE html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="deltaspike-generate-pages">
+<meta name="author" content="chm">
+
+<title>Configure DeltaSpike in Your Projects</title>
+
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file to you under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License.  You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and limitations under the License. -->
+
+<!-- Styles -->
+
+<link href="https://deltaspike.apache.org/resources/css/bootstrap.css" rel="stylesheet">
+<link href="https://deltaspike.apache.org/resources/css/bootstrap-responsive.css" rel="stylesheet">
+
+<style type="text/css">
+/* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
+/*pre.CodeRay {background-color:#f7f7f8;}*/
+.CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
+.CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
+.CodeRay .line-numbers strong{font-weight: normal}
+table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
+table.CodeRay td{vertical-align: top}
+table.CodeRay td.line-numbers{text-align:right}
+table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
+table.CodeRay td.code{padding:0 0 0 .5em}
+table.CodeRay td.code>pre{padding:0}
+.CodeRay .debug{color:#fff !important;background:#000080 !important}
+.CodeRay .annotation{color:#007}
+.CodeRay .attribute-name{color:#000080}
+.CodeRay .attribute-value{color:#700}
+.CodeRay .binary{color:#509}
+.CodeRay .comment{color:#998;font-style:italic}
+.CodeRay .char{color:#04d}
+.CodeRay .char .content{color:#04d}
+.CodeRay .char .delimiter{color:#039}
+.CodeRay .class{color:#458;font-weight:bold}
+.CodeRay .complex{color:#a08}
+.CodeRay .constant,.CodeRay .predefined-constant{color:#008080}
+.CodeRay .color{color:#099}
+.CodeRay .class-variable{color:#369}
+.CodeRay .decorator{color:#b0b}
+.CodeRay .definition{color:#099}
+.CodeRay .delimiter{color:#000}
+.CodeRay .doc{color:#970}
+.CodeRay .doctype{color:#34b}
+.CodeRay .doc-string{color:#d42}
+.CodeRay .escape{color:#666}
+.CodeRay .entity{color:#800}
+.CodeRay .error{color:#808}
+.CodeRay .exception{color:inherit}
+.CodeRay .filename{color:#099}
+.CodeRay .function{color:#900;font-weight:bold}
+.CodeRay .global-variable{color:#008080}
+.CodeRay .hex{color:#058}
+.CodeRay .integer,.CodeRay .float{color:#099}
+.CodeRay .include{color:#555}
+.CodeRay .inline{color:#00}
+.CodeRay .inline .inline{background:#ccc}
+.CodeRay .inline .inline .inline{background:#bbb}
+.CodeRay .inline .inline-delimiter{color:#d14}
+.CodeRay .inline-delimiter{color:#d14}
+.CodeRay .important{color:#555;font-weight:bold}
+.CodeRay .interpreted{color:#b2b}
+.CodeRay .instance-variable{color:#008080}
+.CodeRay .label{color:#970}
+.CodeRay .local-variable{color:#963}
+.CodeRay .octal{color:#40e}
+.CodeRay .predefined{color:#369}
+.CodeRay .preprocessor{color:#579}
+.CodeRay .pseudo-class{color:#555}
+.CodeRay .directive{font-weight:bold}
+.CodeRay .type{font-weight:bold}
+.CodeRay .predefined-type{color:inherit}
+.CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold}
+.CodeRay .key{color:#808}
+.CodeRay .key .delimiter{color:#606}
+.CodeRay .key .char{color:#80f}
+.CodeRay .value{color:#088}
+.CodeRay .regexp .delimiter{color:#808}
+.CodeRay .regexp .content{color:#808}
+.CodeRay .regexp .modifier{color:#808}
+.CodeRay .regexp .char{color:#d14}
+.CodeRay .regexp .function{color:#404;font-weight:bold}
+.CodeRay .string{color:#d20}
+.CodeRay .string .string .string{background:#ffd0d0}
+.CodeRay .string .content{color:#d14}
+.CodeRay .string .char{color:#d14}
+.CodeRay .string .delimiter{color:#d14}
+.CodeRay .shell{color:#d14}
+.CodeRay .shell .delimiter{color:#d14}
+.CodeRay .symbol{color:#990073}
+.CodeRay .symbol .content{color:#a60}
+.CodeRay .symbol .delimiter{color:#630}
+.CodeRay .tag{color:#008080}
+.CodeRay .tag-special{color:#d70}
+.CodeRay .variable{color:#036}
+.CodeRay .insert{background:#afa}
+.CodeRay .delete{background:#faa}
+.CodeRay .change{color:#aaf;background:#007}
+.CodeRay .head{color:#f8f;background:#505}
+.CodeRay .insert .insert{color:#080}
+.CodeRay .delete .delete{color:#800}
+.CodeRay .change .change{color:#66f}
+.CodeRay .head .head{color:#f4f}
+body {
+	padding-top: 60px;
+	padding-bottom: 40px;
+}
+</style>
+<script type="text/javascript">
+
+	  var _gaq = _gaq || [];
+	  _gaq.push(['_setAccount', 'UA-36103647-1']);
+	  _gaq.push(['_trackPageview']);
+	
+	  (function() {
+		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+	  })();
+	
+	</script>
+</head>
+
+<body>
+
+	<div class="navbar navbar-fixed-top">
+		<div class="navbar-inner">
+			<div class="container">
+				<a class="btn btn-navbar" data-toggle="collapse"
+					data-target=".nav-collapse"> <span class="icon-bar"></span> <span
+					class="icon-bar"></span> <span class="icon-bar"></span>
+				</a> <a class="brand logocolor"
+					href="http://deltaspike.apache.org/index.html">Apache
+					DeltaSpike</a>
+				<div class="nav-collapse">
+					<ul class="nav">
+						<li class="active"><a
+							href="http://deltaspike.apache.org/index.html">Home</a></li>
+						<li><a href="http://deltaspike.apache.org/documentation">Documentation</a></li>
+						<li><a href="http://deltaspike.apache.org/source.html">Source</a></li>
+						<li><a href="http://deltaspike.apache.org/download.html">Download</a></li>
+						<li><a href="http://deltaspike.apache.org/community.html">Community</a></li>
+						<!-- <li><a href="./support.html">Support</a></li>  -->
+						<li><a href="http://deltaspike.apache.org/news.html">News</a></li>
+						<li><a
+							href="http://deltaspike.apache.org/migration-guide.html">Migration</a></li>
+					</ul>
+				</div>
+				<!--/.nav-collapse -->
+				<form id="search-form" action="http://www.google.com/search"
+					method="get" class="navbar-search pull-right">
+					<input value="deltaspike.apache.org" name="sitesearch"
+						type="hidden"> <input class="search-query" name="q"
+						id="query" type="text">
+				</form>
+			</div>
+		</div>
+	</div>
+
+	<div class="container">
+		<div class="row">
+			<div class="span12">
+				<div class="page-title">
+			    <h1>Configure DeltaSpike in Your Projects</h1>
+                </div>
+
+				<div id="toc" class="toc">
+       	 		<ul class="sectlevel1">
+<li><a href="#_configure_deltaspike_in_maven_based_projects">Configure DeltaSpike in Maven-based Projects</a></li>
+<li><a href="#_configure_deltaspike_in_maven_independent_projects">Configure DeltaSpike in Maven-independent Projects</a></li>
+<li><a href="#_next">Next</a></li>
+</ul>
+       	 		<hr>	
+       	 		
+				<div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>DeltaSpike is available for use in Maven-based and Maven-independent projects. Instructions are given here for obtaining released final versions of DeltaSpike for both approaches.</p>
+</div>
+<div class="paragraph">
+<p><strong>Note:</strong> You can also opt to use the lastest DeltaSpike snapshots; for more information, see <a href="snapshots.html">Test Snapshots</a>.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configure_deltaspike_in_maven_based_projects">Configure DeltaSpike in Maven-based Projects</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>DeltaSpike released versions are available from the Maven Central repository for use in Maven-based projects. This means that you do not need to modify your Maven configuration <code>settings.xml</code> file; when building projects, Maven automatically searches the online Maven Central repository for project dependencies and downloads sources to your local Maven repository.</p>
+</div>
+<div class="paragraph">
+<p>To begin use the DeltaSpike releases from Maven Central, you simply need to configure the project <code>pom.xml</code> file for each project with information about the release version and modules you want to use. At a minimum, you must add the DeltaSpike Core module, which provides the DeltaSpike API and utility classes.</p>
+</div>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Open the project <code>pom.xml</code> file for editing</p>
+</li>
+<li>
+<p>Add the DeltaSpike version to the list of properties</p>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;properties&gt;</span>
+    <span class="tag">&lt;deltaspike.version&gt;</span>1.0.3<span class="tag">&lt;/deltaspike.version&gt;</span>
+<span class="tag">&lt;/properties&gt;</span></code></pre>
+</div>
+</div>
+</li>
+<li>
+<p>Add the DeltaSpike Core module to the list of dependencies</p>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.core<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-core-api<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>compile<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span>
+
+<span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.core<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-core-impl<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>runtime<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+</li>
+<li>
+<p>Save the <code>pom.xml</code> file changes</p>
+</li>
+</ol>
+</div>
+<div class="paragraph">
+<p>For instructions on adding the optional DeltaSpike modules, see the relevant module page:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a href="bean-validation.html">Bean Validation</a></p>
+</li>
+<li>
+<p><a href="container-control.html">Container Control</a></p>
+</li>
+<li>
+<p><a href="data.html">Data</a></p>
+</li>
+<li>
+<p><a href="jpa.html">JPA</a></p>
+</li>
+<li>
+<p><a href="jsf.html">JSF</a></p>
+</li>
+<li>
+<p><a href="partial-bean.html">Partial-Bean</a></p>
+</li>
+<li>
+<p><a href="scheduler.html">Scheduler</a></p>
+</li>
+<li>
+<p><a href="security.html">Security</a></p>
+</li>
+<li>
+<p><a href="servlet.html">Servlet</a></p>
+</li>
+<li>
+<p><a href="test-control.html">Test-Control</a></p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configure_deltaspike_in_maven_independent_projects">Configure DeltaSpike in Maven-independent Projects</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Deltaspike is provided as a set of downloadable .jar files for projects not utilizing the Maven build system. Alternatively, you can build the DeltaSpike .jar files from source; for instructions, see <a href="build.html">Build DeltaSpike from Source</a>. In both cases, you must add the DeltaSpike .jar files directly to your projects.</p>
+</div>
+<div class="paragraph">
+<p>To use DeltaSpike without Maven from the downloadable .jar files, complete the following steps:</p>
+</div>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Download the latest <code>distribution-full-&lt;version&gt;.zip</code> from <a href="https://deltaspike.apache.org/download.html" class="bare">https://deltaspike.apache.org/download.html</a></p>
+</li>
+<li>
+<p>Extract the archive contents</p>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="shell">$ unzip distribution-full-&lt;version&gt;.zip</code></pre>
+</div>
+</div>
+</li>
+<li>
+<p>Add the source to your project</p>
+<div class="olist loweralpha">
+<ol class="loweralpha" type="a">
+<li>
+<p>For .war projects, copy the .jar files to <code>WEB-INF/lib</code> directory</p>
+</li>
+<li>
+<p>For .ear projects, copy the .jar files to <code>EAR/lib directory</code> and add the following to <code>META-INF/application.xml</code>:</p>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;library-directory&gt;</span>lib<span class="tag">&lt;/library-directory&gt;</span></code></pre>
+</div>
+</div>
+</li>
+</ol>
+</div>
+</li>
+</ol>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_next">Next</h2>
+<div class="sectionbody">
+<div class="ulist">
+<ul>
+<li>
+<p>To check whether your Java envrionment needs any additional CDI-specific configuration, see <a href="cdiimp.html">Enable CDI For Your Java Environment</a>.</p>
+</li>
+<li>
+<p>To see ready-to-deploy example DeltaSpike applications, see <a href="examples.html">See DeltaSpike in Action</a>.</p>
+</li>
+<li>
+<p>To understand how the various DeltaSpike modules can enhance and extend your applications, see the individual module pages.</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+			</div>
+
+			<hr>
+
+			<footer>
+				<p>Copyright © 2011-2014 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.</p>
+				<p>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
+			</footer>
+
+		</div>
+		<!-- /.container -->
+
+</body>
+</html>
\ No newline at end of file

Added: websites/staging/deltaspike/trunk/content/documentation/staging/container-control.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/documentation/staging/container-control.html (added)
+++ websites/staging/deltaspike/trunk/content/documentation/staging/container-control.html Wed Oct 15 13:19:37 2014
@@ -0,0 +1,428 @@
+<!DOCTYPE html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="deltaspike-generate-pages">
+<meta name="author" content="chm">
+
+<title>Container &amp; Control</title>
+
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file to you under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License.  You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and limitations under the License. -->
+
+<!-- Styles -->
+
+<link href="https://deltaspike.apache.org/resources/css/bootstrap.css" rel="stylesheet">
+<link href="https://deltaspike.apache.org/resources/css/bootstrap-responsive.css" rel="stylesheet">
+
+<style type="text/css">
+/* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
+/*pre.CodeRay {background-color:#f7f7f8;}*/
+.CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
+.CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
+.CodeRay .line-numbers strong{font-weight: normal}
+table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
+table.CodeRay td{vertical-align: top}
+table.CodeRay td.line-numbers{text-align:right}
+table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
+table.CodeRay td.code{padding:0 0 0 .5em}
+table.CodeRay td.code>pre{padding:0}
+.CodeRay .debug{color:#fff !important;background:#000080 !important}
+.CodeRay .annotation{color:#007}
+.CodeRay .attribute-name{color:#000080}
+.CodeRay .attribute-value{color:#700}
+.CodeRay .binary{color:#509}
+.CodeRay .comment{color:#998;font-style:italic}
+.CodeRay .char{color:#04d}
+.CodeRay .char .content{color:#04d}
+.CodeRay .char .delimiter{color:#039}
+.CodeRay .class{color:#458;font-weight:bold}
+.CodeRay .complex{color:#a08}
+.CodeRay .constant,.CodeRay .predefined-constant{color:#008080}
+.CodeRay .color{color:#099}
+.CodeRay .class-variable{color:#369}
+.CodeRay .decorator{color:#b0b}
+.CodeRay .definition{color:#099}
+.CodeRay .delimiter{color:#000}
+.CodeRay .doc{color:#970}
+.CodeRay .doctype{color:#34b}
+.CodeRay .doc-string{color:#d42}
+.CodeRay .escape{color:#666}
+.CodeRay .entity{color:#800}
+.CodeRay .error{color:#808}
+.CodeRay .exception{color:inherit}
+.CodeRay .filename{color:#099}
+.CodeRay .function{color:#900;font-weight:bold}
+.CodeRay .global-variable{color:#008080}
+.CodeRay .hex{color:#058}
+.CodeRay .integer,.CodeRay .float{color:#099}
+.CodeRay .include{color:#555}
+.CodeRay .inline{color:#00}
+.CodeRay .inline .inline{background:#ccc}
+.CodeRay .inline .inline .inline{background:#bbb}
+.CodeRay .inline .inline-delimiter{color:#d14}
+.CodeRay .inline-delimiter{color:#d14}
+.CodeRay .important{color:#555;font-weight:bold}
+.CodeRay .interpreted{color:#b2b}
+.CodeRay .instance-variable{color:#008080}
+.CodeRay .label{color:#970}
+.CodeRay .local-variable{color:#963}
+.CodeRay .octal{color:#40e}
+.CodeRay .predefined{color:#369}
+.CodeRay .preprocessor{color:#579}
+.CodeRay .pseudo-class{color:#555}
+.CodeRay .directive{font-weight:bold}
+.CodeRay .type{font-weight:bold}
+.CodeRay .predefined-type{color:inherit}
+.CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold}
+.CodeRay .key{color:#808}
+.CodeRay .key .delimiter{color:#606}
+.CodeRay .key .char{color:#80f}
+.CodeRay .value{color:#088}
+.CodeRay .regexp .delimiter{color:#808}
+.CodeRay .regexp .content{color:#808}
+.CodeRay .regexp .modifier{color:#808}
+.CodeRay .regexp .char{color:#d14}
+.CodeRay .regexp .function{color:#404;font-weight:bold}
+.CodeRay .string{color:#d20}
+.CodeRay .string .string .string{background:#ffd0d0}
+.CodeRay .string .content{color:#d14}
+.CodeRay .string .char{color:#d14}
+.CodeRay .string .delimiter{color:#d14}
+.CodeRay .shell{color:#d14}
+.CodeRay .shell .delimiter{color:#d14}
+.CodeRay .symbol{color:#990073}
+.CodeRay .symbol .content{color:#a60}
+.CodeRay .symbol .delimiter{color:#630}
+.CodeRay .tag{color:#008080}
+.CodeRay .tag-special{color:#d70}
+.CodeRay .variable{color:#036}
+.CodeRay .insert{background:#afa}
+.CodeRay .delete{background:#faa}
+.CodeRay .change{color:#aaf;background:#007}
+.CodeRay .head{color:#f8f;background:#505}
+.CodeRay .insert .insert{color:#080}
+.CodeRay .delete .delete{color:#800}
+.CodeRay .change .change{color:#66f}
+.CodeRay .head .head{color:#f4f}
+body {
+	padding-top: 60px;
+	padding-bottom: 40px;
+}
+</style>
+<script type="text/javascript">
+
+	  var _gaq = _gaq || [];
+	  _gaq.push(['_setAccount', 'UA-36103647-1']);
+	  _gaq.push(['_trackPageview']);
+	
+	  (function() {
+		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+	  })();
+	
+	</script>
+</head>
+
+<body>
+
+	<div class="navbar navbar-fixed-top">
+		<div class="navbar-inner">
+			<div class="container">
+				<a class="btn btn-navbar" data-toggle="collapse"
+					data-target=".nav-collapse"> <span class="icon-bar"></span> <span
+					class="icon-bar"></span> <span class="icon-bar"></span>
+				</a> <a class="brand logocolor"
+					href="http://deltaspike.apache.org/index.html">Apache
+					DeltaSpike</a>
+				<div class="nav-collapse">
+					<ul class="nav">
+						<li class="active"><a
+							href="http://deltaspike.apache.org/index.html">Home</a></li>
+						<li><a href="http://deltaspike.apache.org/documentation">Documentation</a></li>
+						<li><a href="http://deltaspike.apache.org/source.html">Source</a></li>
+						<li><a href="http://deltaspike.apache.org/download.html">Download</a></li>
+						<li><a href="http://deltaspike.apache.org/community.html">Community</a></li>
+						<!-- <li><a href="./support.html">Support</a></li>  -->
+						<li><a href="http://deltaspike.apache.org/news.html">News</a></li>
+						<li><a
+							href="http://deltaspike.apache.org/migration-guide.html">Migration</a></li>
+					</ul>
+				</div>
+				<!--/.nav-collapse -->
+				<form id="search-form" action="http://www.google.com/search"
+					method="get" class="navbar-search pull-right">
+					<input value="deltaspike.apache.org" name="sitesearch"
+						type="hidden"> <input class="search-query" name="q"
+						id="query" type="text">
+				</form>
+			</div>
+		</div>
+	</div>
+
+	<div class="container">
+		<div class="row">
+			<div class="span12">
+				<div class="page-title">
+			    <h1>Container &amp; Control</h1>
+                </div>
+
+				<div id="toc" class="toc">
+       	 		<ul class="sectlevel1">
+<li><a href="#_introduction">Introduction</a>
+<ul class="sectlevel2">
+<li><a href="#_cdicontainer">CdiContainer</a></li>
+<li><a href="#_contextcontrol_usage">ContextControl usage</a></li>
+<li><a href="#_embedded_servlet_support">Embedded Servlet Support</a>
+<ul class="sectlevel3">
+<li><a href="#_jetty">Jetty</a></li>
+<li><a href="#_undertow">Undertow</a></li>
+<li><a href="#_tomcat">Tomcat</a></li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+       	 		<hr>	
+       	 		
+				<div class="sect1">
+<h2 id="_introduction">Introduction</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>There are basically two parts:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>The <code>CdiContainer</code> interface allows to boot and shutdown the CDI container in SE applications.</p>
+</li>
+<li>
+<p>The <code>ContextControl</code> interface allows to control the life-cycle of the built-in contexts of the CDI container.</p>
+</li>
+</ul>
+</div>
+<div class="sect2">
+<h3 id="_cdicontainer">CdiContainer</h3>
+<div class="paragraph">
+<p>You can use the <code>CdiContainerLoader</code> as a simple factory to gain access
+to the underlying <code>CdiContainer</code> implementation. This is of little
+interest for Java EE applications since the CDI Container already gets
+properly booted and shut down by the Servlet container integration.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="comment">// this will give you a CdiContainer for Weld or OWB, depending on the jar you added</span>
+CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
+
+<span class="comment">// now we gonna boot the CDI container. This will trigger the classpath scan, etc</span>
+cdiContainer.boot();
+
+<span class="comment">// and finally we like to start all built-in contexts</span>
+cdiContainer.getContextControl().startContexts();
+
+<span class="comment">// now we can use CDI in our SE application.</span>
+<span class="comment">// And there is not a single line of OWB or Weld specific code in your project!</span>
+
+<span class="comment">// finally we gonna stop the container</span>
+cdiContainer.shutdown();</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_contextcontrol_usage">ContextControl usage</h3>
+<div class="paragraph">
+<p>The <code>ContextControl</code> interface allows you to start and stop built-in
+standard Contexts like <code>@RequestScoped</code>, <code>@ConversationScoped</code>,
+<code>@SessionScoped</code>, etc. It is provided as <code>@Dependent</code> bean and can get
+injected in the classic CDI way. This is not only usable in Java SE
+projects but also very helpful in Servlets and Java EE containers.</p>
+</div>
+<div class="paragraph">
+<p><strong>Restarting the RequestContext in unit tests</strong></p>
+</div>
+<div class="paragraph">
+<p>In unit testing it can be necessary to test with attached and also with
+detached JPA entities. A very common approach for JPA is the
+<a href="http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Web_Server/1.0/html/Hibernate_Entity_Manager_Reference_Guide/transactions.html">entitymanager-per-request
+approach</a> and thus have a producer method which creates a @RequestScoped
+EntityManager. Since a single unit test is usually treated as one
+‘request’ a problem arises detaching entities.</p>
+</div>
+<div class="paragraph">
+<p>Using ContextControl to detach entities:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@Test</span>
+<span class="directive">public</span> <span class="type">void</span> testMyBusinessLogic()
+{
+    doSomeJpaStuff()
+    MyEntity me = em.find(...);
+
+    ContextControl ctxCtrl = BeanProvider.getContextualReference(ContextControl.class);
+
+    <span class="comment">//stopping the request context will dispose the @RequestScoped EntityManager</span>
+    ctxCtrl.stopContext(RequestScoped.class);
+
+    <span class="comment">// and now immediately restart the context again</span>
+    ctxCtrl.startContext(RequestScoped.class);
+
+    <span class="comment">// the entity 'em' is now in a detached state!</span>
+    doSomeStuffWithTheDetachedEntity(em);
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Attaching a Request Context to a new thread in EE</p>
+</div>
+<div class="paragraph">
+<p>Accessing the <code>@RequestScoped</code> bean in a new thread will result in a
+<code>ContextNotActiveException</code>. The request-context usually gets started
+for a particular thread via a simple <code>ServletRequestListener</code>. So "no
+servlet-request" means that there is no Servlet-Context for the current
+(/new) Thread. You might face such issues, if you would like to reuse
+business services in e.g. a Quartz Job.</p>
+</div>
+<div class="paragraph">
+<p>Controlling the request-context for a Quartz-Job:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">CdiJob</span> <span class="directive">implements</span> org.quartz.Job
+{
+    <span class="directive">public</span> <span class="type">void</span> execute(JobExecutionContext context) <span class="directive">throws</span> JobExecutionException
+    {
+        ContextControl ctxCtrl = BeanProvider.getContextualReference(ContextControl.class);
+
+        <span class="comment">//this will implicitly bind a new RequestContext to the current thread</span>
+        ctxCtrl.startContext(RequestScoped.class);
+
+        <span class="keyword">try</span>
+        {
+            doYourWork();
+        }
+        <span class="keyword">finally</span>
+        {
+            <span class="comment">//stop the RequestContext to ensure that all request-scoped beans get cleaned up.</span>
+            ctxCtrl.stopContext(RequestScoped.class);
+        }
+    }
+}</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_embedded_servlet_support">Embedded Servlet Support</h3>
+<div class="paragraph">
+<p>Starting with 1.0.2, you can use DeltaSpike to power embedded Servlet
+runtimes. This work is done via Servlet Listeners. The configuration is
+specific to each container, below are some examples.</p>
+</div>
+<div class="paragraph">
+<p>The two main listeners are <code>CdiServletRequestListener</code> and
+<code>CdiServletContextListener</code>. <code>CdiServletRequestListener</code> is responsible
+for starting a <code>RequestContext</code> on each incoming request. In most
+containers this is all you need. For Tomcat specifically, you need to
+use <code>CdiServletContextListener</code> which registers the
+<code>CdiServletRequestListener</code>.</p>
+</div>
+<div class="paragraph">
+<p>The main usecase for this feature is for lightweight embedded runtimes,
+microservices. For each of these, it is assumed that you are using the
+following start up code somewhere:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java">CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
+cdiContainer.boot();
+cdiContainer.getContextControl().startContexts();</code></pre>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_jetty">Jetty</h4>
+<div class="paragraph">
+<p>For Jetty, you need to add an <code>EventListener</code> which will be your
+<code>CdiServletRequestListener</code>. The object must be instantiated. This must
+be done before the server is started.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java">Server server = <span class="keyword">new</span> Server(port);
+ServletContextHandler context = <span class="keyword">new</span> ServletContextHandler(ServletContextHandler.SESSIONS);
+context.setContextPath(<span class="string"><span class="delimiter">&quot;</span><span class="content">/</span><span class="delimiter">&quot;</span></span>);
+server.setHandler(context);
+
+context.addEventListener(<span class="keyword">new</span> CdiServletRequestListener());
+context.addServlet(<span class="keyword">new</span> ServletHolder(<span class="keyword">new</span> YourServlet()),<span class="string"><span class="delimiter">&quot;</span><span class="content">/*</span><span class="delimiter">&quot;</span></span>);
+
+server.start();</code></pre>
+</div>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_undertow">Undertow</h4>
+<div class="paragraph">
+<p>For Undertow, you register the <code>CdiServletRequestListener</code> via
+<code>ListenerInfo</code> by passing in the class to their builders. Then you add
+the <code>ListenerInfo</code> to your deployment before starting.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java">ServletInfo servletInfo = Servlets.servlet(<span class="string"><span class="delimiter">&quot;</span><span class="content">YourServletName</span><span class="delimiter">&quot;</span></span>, YourServlet.class).setAsyncSupported(<span class="predefined-constant">true</span>)
+    .setLoadOnStartup(<span class="integer">1</span>).addMapping(<span class="string"><span class="delimiter">&quot;</span><span class="content">/*</span><span class="delimiter">&quot;</span></span>);
+ListenerInfo listenerInfo = Servlets.listener(CdiServletRequestListener.class);
+DeploymentInfo di = <span class="keyword">new</span> DeploymentInfo()
+        .addListener(listenerInfo)
+        .setContextPath(<span class="string"><span class="delimiter">&quot;</span><span class="content">/</span><span class="delimiter">&quot;</span></span>)
+        .addServlet(servletInfo).setDeploymentName(<span class="string"><span class="delimiter">&quot;</span><span class="content">CdiSEServlet</span><span class="delimiter">&quot;</span></span>)
+        .setClassLoader(<span class="predefined-type">ClassLoader</span>.getSystemClassLoader());
+DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(di);
+deploymentManager.deploy();
+Undertow server = Undertow.builder()
+        .addHttpListener(port, <span class="string"><span class="delimiter">&quot;</span><span class="content">localhost</span><span class="delimiter">&quot;</span></span>)
+        .setHandler(deploymentManager.start())
+        .build();
+server.start();</code></pre>
+</div>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_tomcat">Tomcat</h4>
+<div class="paragraph">
+<p>For Tomcat, you need to register the <code>CdiServletContextListener</code> instead
+of the <code>CdiServletRequestListener</code>. It is added as an
+<code>ApplicationListener</code> by passing in the class name as a <code>String</code>.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java">Tomcat tomcat = <span class="keyword">new</span> Tomcat();
+tomcat.setPort(port);
+<span class="predefined-type">File</span> base = <span class="keyword">new</span> <span class="predefined-type">File</span>(<span class="string"><span class="delimiter">&quot;</span><span class="content">...</span><span class="delimiter">&quot;</span></span>);
+<span class="predefined-type">Context</span> ctx = tomcat.addContext(<span class="string"><span class="delimiter">&quot;</span><span class="content">/</span><span class="delimiter">&quot;</span></span>,base.getAbsolutePath());
+StandardContext standardContext = (StandardContext)ctx;
+standardContext.addApplicationListener(CdiServletContextListener.class.getName());
+Wrapper wrapper = Tomcat.addServlet(ctx,<span class="string"><span class="delimiter">&quot;</span><span class="content">YourServlet</span><span class="delimiter">&quot;</span></span>,YourServlet.class.getName());
+wrapper.addMapping(<span class="string"><span class="delimiter">&quot;</span><span class="content">/*</span><span class="delimiter">&quot;</span></span>);
+tomcat.start();</code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+			</div>
+
+			<hr>
+
+			<footer>
+				<p>Copyright © 2011-2014 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.</p>
+				<p>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
+			</footer>
+
+		</div>
+		<!-- /.container -->
+
+</body>
+</html>
\ No newline at end of file



Mime
View raw message