deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r925956 [10/10] - in /websites/staging/deltaspike/trunk/content: ./ documentation/staging/
Date Thu, 16 Oct 2014 13:29:03 GMT
Added: websites/staging/deltaspike/trunk/content/documentation/staging/spi.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/documentation/staging/spi.html (added)
+++ websites/staging/deltaspike/trunk/content/documentation/staging/spi.html Thu Oct 16 13:29:02 2014
@@ -0,0 +1,343 @@
+<!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 Service Provider Interface (SPI)</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 Service Provider Interface (SPI)</h1>
+                </div>
+
+				<div id="toc" class="toc">
+       	 		<ul class="sectlevel1">
+<li><a href="#_introduction">Introduction</a></li>
+<li><a href="#_deactivatable">Deactivatable</a>
+<ul class="sectlevel2">
+<li><a href="#_classdeactivator">ClassDeactivator</a></li>
+</ul>
+</li>
+<li><a href="#_configsource">ConfigSource</a>
+<ul class="sectlevel2">
+<li><a href="#_configsourceprovider">ConfigSourceProvider</a></li>
+<li><a href="#_baseconfigpropertyproducer">BaseConfigPropertyProducer</a></li>
+</ul>
+</li>
+<li><a href="#_interceptorstrategy">InterceptorStrategy</a></li>
+<li><a href="#_global_alternative">Global Alternative</a></li>
+</ul>
+       	 		<hr>	
+       	 		
+				<div class="sect1">
+<h2 id="_introduction">Introduction</h2>
+<div class="sectionbody">
+
+</div>
+</div>
+<div class="sect1">
+<h2 id="_deactivatable">Deactivatable</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This mechanism is only used for artifacts <strong>like</strong> implementations of
+(<code>javax.enterprise.inject.spi.Extension</code>) which <strong>can&#8217;t</strong> be deactivated
+with std. CDI mechanisms.</p>
+</div>
+<div class="paragraph">
+<p>This interface is just a marker interface which is implemented by all
+pre-configured DeltaSpike artifacts which can be deactivated manually
+(e.g. to improve the performance if a part isn&#8217;t needed, to provide a
+custom implementation if the default implementation isn&#8217;t pluggable by
+default or to bypass an implementation which causes an issue (in this
+case please also <strong>contact us</strong> and we will fix it)).</p>
+</div>
+<div class="paragraph">
+<p>To deactivate a class it&#8217;s required to implement <code>ClassDeactivator</code>.
+Returning 'false' or 'true' allows to de-/activate the class in
+question. Retuning null means that the current class-deactivator doesn&#8217;t
+have information about the class in question and can&#8217;t provide a result.
+Since <code>ClassDeactivator</code> implementations are configured with the
+low-level config of DeltaSpike, the class-deactivator with the highest
+ordinal has the final decision. DeltaSpike itself doesn&#8217;t deactivate an
+implementation, however, an add-on or a 3rd party portable CDI extension
+based on DeltaSpike (Core+) can use the concept to deactivate a default
+implementation of DeltaSpike in favour of its own implementation.</p>
+</div>
+<div class="paragraph">
+<p><strong>Attention</strong>: due to the ordinal feature of the low-level config
+approach it&#8217;s possible that a class-deactivator with a higher ordinal,
+e.g. used in a concrete project, can re-activate a deactivated
+implementation.<br>
+<strong>Please note</strong> that you might have to deactivate the parts of the add-on
+or 3rd party CDI extension which relies on its own implementation.
+Therefore, you should <strong>be really careful with re-activation</strong>.) The
+implementation should be stateless because the result will be cached and
+as soon as everything is initialized the class-deactivators won&#8217;t be
+used any longer.</p>
+</div>
+<div class="sect2">
+<h3 id="_classdeactivator">ClassDeactivator</h3>
+<div class="paragraph">
+<p>A class-deactivator allows to specify deactivated classes.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="comment">//This class needs to be configured via one of the supported config sources!</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">CustomClassDeactivator</span> <span class="directive">implements</span> ClassDeactivator
+{
+    <span class="annotation">@Override</span>
+    <span class="directive">public</span> <span class="predefined-type">Boolean</span> isActivated(<span class="predefined-type">Class</span>&lt;? <span class="directive">extends</span> Deactivatable&gt; targetClass)
+    {
+        <span class="keyword">if</span> (targetClass.equals(MyClass.class))
+        {
+            <span class="keyword">return</span> <span class="predefined-type">Boolean</span>.FALSE;
+        }
+        <span class="keyword">return</span> <span class="predefined-constant">null</span>; <span class="comment">//no result for the given class</span>
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>A class-deactivator will be resolved from the environment via the
+default resolvers or via a custom resolver which allows to use any type
+of configuration-format. (see
+<code>org.apache.deltaspike.core.api.config.ConfigResolver</code>). The key is the
+fully qualified name of the interface
+(<code>org.apache.deltaspike.core.spi.activation.ClassDeactivator</code>).</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configsource">ConfigSource</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_configsourceprovider">ConfigSourceProvider</h3>
+
+</div>
+<div class="sect2">
+<h3 id="_baseconfigpropertyproducer">BaseConfigPropertyProducer</h3>
+
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_interceptorstrategy">InterceptorStrategy</h2>
+<div class="sectionbody">
+
+</div>
+</div>
+<div class="sect1">
+<h2 id="_global_alternative">Global Alternative</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>There are several application servers (using CDI 1.0) which can&#8217;t handle
+alternative CDI beans correctly (e.g. due to a too strict interpretation
+or a broken implementation). Therefore, DeltaSpike allows to use the
+std. <code>@Alternative</code> annotation and an additional config entry for
+DeltaSpike which allows to use the alternative implementation as a
+global alternative.</p>
+</div>
+<div class="paragraph">
+<p><strong>Std. CDI alternative implementation (without the required XML config)</strong></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">CustomBean</span>
+{
+}
+
+<span class="annotation">@Alternative</span>
+<span class="comment">//...</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">AlternativeCustomBean</span> <span class="directive">extends</span> CustomBean
+{
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Instead of configuring the alternative in the beans.xml, a global
+alternative needs to be configured in
+/META-INF/apache-deltaspike.properties. CDI 1.1 should fix this issue
+and migrating to it means to remove the config entry for DeltaSpike
+again and move to the std. CDI config approach.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>custom.CustomBean=custom.AlternativeCustomBean</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/test-control.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/documentation/staging/test-control.html (added)
+++ websites/staging/deltaspike/trunk/content/documentation/staging/test-control.html Thu Oct 16 13:29:02 2014
@@ -0,0 +1,704 @@
+<!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>Test-Control Module</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>Test-Control Module</h1>
+                </div>
+
+				<div id="toc" class="toc">
+       	 		<ul class="sectlevel1">
+<li><a href="#_intro">Intro</a></li>
+<li><a href="#_setup">Setup</a>
+<ul class="sectlevel2">
+<li><a href="#_openwebbeans">OpenWebBeans</a></li>
+<li><a href="#_weld">Weld</a></li>
+</ul>
+</li>
+<li><a href="#_cditestrunner">CdiTestRunner</a></li>
+<li><a href="#__testcontrol">@TestControl</a></li>
+<li><a href="#_cditestsuiterunner">CdiTestSuiteRunner</a></li>
+<li><a href="#_project_stage_control">Project-Stage Control</a></li>
+<li><a href="#_optional_config">Optional Config</a></li>
+<li><a href="#_hints">Hints</a></li>
+<li><a href="#_optional_integrations">Optional Integrations</a>
+<ul class="sectlevel2">
+<li><a href="#_mock_frameworks">Mock Frameworks</a></li>
+<li><a href="#_jsf_via_myfaces_test">JSF (via MyFaces-Test)</a></li>
+</ul>
+</li>
+<li><a href="#_mixed_tests">Mixed Tests</a></li>
+<li><a href="#_known_restrictions">Known Restrictions</a>
+<ul class="sectlevel2">
+<li><a href="#_liquibase">Liquibase</a></li>
+</ul>
+</li>
+<li><a href="#_spi">SPI</a>
+<ul class="sectlevel2">
+<li><a href="#_externalcontainer">ExternalContainer</a></li>
+</ul>
+</li>
+</ul>
+       	 		<hr>	
+       	 		
+				<div class="sect1">
+<h2 id="_intro">Intro</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This module is available since version 0.6 and allows to write CDI based
+tests easily.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_setup">Setup</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Setup for the CDI implementation of your choice and the following
+test-dependencies:</p>
+</div>
+<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.modules<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-test-control-module-api<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${ds.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<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.modules<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-test-control-module-impl<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${ds.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_openwebbeans">OpenWebBeans</h3>
+<div class="paragraph">
+<p>If you are using OpenWebBeans also add the following test-dependency</p>
+</div>
+<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.cdictrl<span class="tag">&lt;/groupId&gt;</span>
+     <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-owb<span class="tag">&lt;/artifactId&gt;</span>
+     <span class="tag">&lt;version&gt;</span>${ds.version}<span class="tag">&lt;/version&gt;</span>
+     <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+ <span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_weld">Weld</h3>
+<div class="paragraph">
+<p>If you are using Weld also add the following test-dependency</p>
+</div>
+<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.cdictrl<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-weld<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${ds.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_cditestrunner">CdiTestRunner</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>JUnit Test-Runner to start/stop the CDI-Container autom. (per
+test-class) and one request and session per test-method:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">ContainerAndInjectionControl</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> ApplicationScopedBean applicationScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> SessionScopedBean sessionScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> RequestScopedBean requestScopedBean;
+
+    <span class="comment">//test the injected beans</span>
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="__testcontrol">@TestControl</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>@TestControl allows to change the default-behavior. In the following
+case only one session for all test-methods (of the test-class) will be
+created:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="annotation">@TestControl</span>(startScopes = SessionScoped.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">CustomizedScopeHandling</span>
+{
+    <span class="comment">//inject beans and test them</span>
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_cditestsuiterunner">CdiTestSuiteRunner</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>JUnit Test-Suite-Runner to start/stop the CDI-Container autom. (per
+test-suite):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestSuiteRunner.class)
+<span class="annotation">@Suite</span>.SuiteClasses({
+    TestX.class,
+    TestY.class
+})
+<span class="directive">public</span> <span class="type">class</span> <span class="class">SuiteLevelContainerControl</span>
+{
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_project_stage_control">Project-Stage Control</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>It&#8217;s possible to overrule the default-project-stage for unit-tests
+(ProjectStage.UnitTest.class):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="annotation">@TestControl</span>(projectStage = CustomTestStage.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">TestStageControl</span>
+{
+    <span class="comment">//tests here will see project-stage CustomTestStage.class</span>
+
+    <span class="annotation">@Test</span>
+    <span class="annotation">@TestControl</span>(projectStage = ProjectStage.Development.class)
+    <span class="directive">public</span> <span class="type">void</span> checkDevEnv()
+    {
+    }
+
+    <span class="comment">//tests here will see project-stage CustomTestStage.class</span>
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_optional_config">Optional Config</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>It&#8217;s possible to set "deltaspike.testcontrol.stop_container" to "false"
+(via the std. DeltaSpike config). With that the CDI-Container will be
+started just once for all tests.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hints">Hints</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Don&#8217;t forget to add a beans.xml in the test-module (e.g.
+src/test/resources/META-INF/beans.xml).</p>
+</div>
+<div class="paragraph">
+<p>If you are using OpenWebBeans as CDI implementation and you need to test
+EJBs as well, you can use deltaspike-cdictrl-openejb<br>
+org.apache.openejb:openejb-core (instead of deltaspike-cdictrl-owb).</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_optional_integrations">Optional Integrations</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_mock_frameworks">Mock Frameworks</h3>
+<div class="paragraph">
+<p>With v0.8+ it&#8217;s possible to mock CDI-Beans. Usually @Exclude (+
+project-stage) is enough, however, for some cases mocked beans might be
+easier. Therefore it&#8217;s possible to create (mock-)instances manually or
+via a mocking framework and add them e.g. via <code>DynamicMockManager</code>.</p>
+</div>
+<div class="paragraph">
+<p>If you need dependency-injection in the mocked instances, you can use
+<code>BeanProvider.injectFields(myMockedBean);</code>.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedRequestScopedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> RequestScopedBean requestScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> DynamicMockManager mockManager;
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> manualMock()
+    {
+        mockManager.addMock(<span class="keyword">new</span> RequestScopedBean() {
+            <span class="annotation">@Override</span>
+            <span class="directive">public</span> <span class="type">int</span> getCount()
+            {
+                <span class="keyword">return</span> <span class="integer">7</span>;
+            }
+        });
+
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+    }
+}
+
+<span class="annotation">@RequestScoped</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">RequestScopedBean</span>
+{
+    <span class="directive">private</span> <span class="type">int</span> count = <span class="integer">0</span>;
+
+    <span class="directive">public</span> <span class="type">int</span> getCount()
+    {
+        <span class="keyword">return</span> count;
+    }
+
+    <span class="directive">public</span> <span class="type">void</span> increaseCount()
+    {
+        <span class="local-variable">this</span>.count++;
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Using a mocking framework makes no difference for adding the mock. E.g.
+via Mockito:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockitoMockedRequestScopedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> RequestScopedBean requestScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> DynamicMockManager mockManager;
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> mockitoMockAsCdiBean()
+    {
+        RequestScopedBean mockedRequestScopedBean = mock(RequestScopedBean.class);
+        when(mockedRequestScopedBean.getCount()).thenReturn(<span class="integer">7</span>);
+        mockManager.addMock(mockedRequestScopedBean);
+
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Since CDI implementations like OpenWebBeans use a lot of optimizations,
+it&#8217;s required to handle mocks for application-scoped beans differently -
+e.g.:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedApplicationScopedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> ApplicationScopedBean applicationScopedBean;
+
+    <span class="annotation">@BeforeClass</span>
+    <span class="directive">public</span> <span class="directive">static</span> <span class="type">void</span> init()
+    {
+        ApplicationMockManager applicationMockManager = BeanProvider.getContextualReference(ApplicationMockManager.class);
+        applicationMockManager.addMock(<span class="keyword">new</span> MockedApplicationScopedBean());
+    }
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> manualMock()
+    {
+        Assert.assertEquals(<span class="integer">14</span>, applicationScopedBean.getCount());
+        applicationScopedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">14</span>, applicationScopedBean.getCount());
+    }
+}
+
+<span class="annotation">@ApplicationScoped</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">ApplicationScopedBean</span>
+{
+    <span class="directive">private</span> <span class="type">int</span> count = <span class="integer">0</span>;
+
+    <span class="directive">public</span> <span class="type">int</span> getCount()
+    {
+        <span class="keyword">return</span> count;
+    }
+
+    <span class="directive">public</span> <span class="type">void</span> increaseCount()
+    {
+        <span class="local-variable">this</span>.count++;
+    }
+}
+
+<span class="annotation">@Typed</span>() <span class="comment">//exclude it for the cdi type-check</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedApplicationScopedBean</span> <span class="directive">extends</span> ApplicationScopedBean
+{
+    <span class="annotation">@Override</span>
+    <span class="directive">public</span> <span class="type">int</span> getCount()
+    {
+        <span class="keyword">return</span> <span class="integer">14</span>;
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>However, <code>ApplicationMockManager</code> can be used for adding all mocks, if
+they should be active for the lifetime of the CDI-container.</p>
+</div>
+<div class="paragraph">
+<p>It&#8217;s also possible to mock qualified beans. Just add the
+literal-instance(s) as additional parameter(s) - e.g.:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedQualifiedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="annotation">@MyQualifier</span>
+    <span class="directive">private</span> QualifiedBean qualifiedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> DynamicMockManager mockManager;
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> manualMockWithQualifier()
+    {
+        mockManager.addMock(<span class="keyword">new</span> QualifiedBean() {
+            <span class="annotation">@Override</span>
+            <span class="directive">public</span> <span class="type">int</span> getCount()
+            {
+                <span class="keyword">return</span> <span class="integer">21</span>;
+            }
+        }, AnnotationInstanceProvider.of(MyQualifier.class));
+
+        Assert.assertEquals(<span class="integer">21</span>, qualifiedBean.getCount());
+        qualifiedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">21</span>, qualifiedBean.getCount());
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In some cases it&#8217;s needed to use <code>@javax.enterprise.inject.Typed</code>.
+Mocking such typed beans can result in an
+<code>AmbiguousResolutionException</code>. Therefore it&#8217;s needed to exclude the
+mocked implementation via <code>@Exclude</code> or <code>@Typed()</code> (or a parametrized
+constructor) and specify the target-type via <code>@TypedMock</code>.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_jsf_via_myfaces_test">JSF (via MyFaces-Test)</h3>
+<div class="paragraph">
+<p>add on of</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MockedJsf2TestContainer</p>
+</li>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MockedJsfTestContainerAdapter</p>
+</li>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerAdapter</p>
+</li>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerPerTestMethodAdapter</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>as content to</p>
+</div>
+<div class="paragraph">
+<p>/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer</p>
+</div>
+<div class="paragraph">
+<p>(in your config-folder for tests e.g.: test/resources)</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_mixed_tests">Mixed Tests</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Usually you should have one kind of tests per test-module. However, if
+you need to add e.g. a test without an external-container to your
+test-module which uses external-containers, you can annotate your test
+with:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="annotation">@TestControl</span>(startExternalContainers = <span class="predefined-constant">false</span>)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">JsfContainerTest</span>
+{
+    <span class="comment">//...</span>
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_known_restrictions">Known Restrictions</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_liquibase">Liquibase</h3>
+<div class="paragraph">
+<p>Liquibase invokes <code>#toString</code> in a <code>AfterDeploymentValidation</code> observer.
+<strong>that isn&#8217;t portable</strong> and therefore you have to deactivate the
+mocking-support via:</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">LiquibaseAwareClassDeactivator</span> <span class="directive">implements</span> ClassDeactivator {
+    <span class="annotation">@Override</span>
+    <span class="directive">public</span> <span class="predefined-type">Boolean</span> isActivated(<span class="predefined-type">Class</span>&lt;? <span class="directive">extends</span> Deactivatable&gt; targetClass) {
+        <span class="keyword">return</span> !<span class="string"><span class="delimiter">&quot;</span><span class="content">org.apache.deltaspike.testcontrol.impl.mock.MockExtension</span><span class="delimiter">&quot;</span></span>.equals(targetClass.getName());
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>and add <code>LiquibaseAwareClassDeactivator</code> to <code>/META-INF/apache-deltaspike.properties</code> - e.g.:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>org.apache.deltaspike.core.spi.activation.ClassDeactivator=myPackage.LiquibaseAwareClassDeactivator</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Further details are available at deactivatable.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_spi">SPI</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_externalcontainer">ExternalContainer</h3>
+<div class="paragraph">
+<p>org.apache.deltaspike.testcontrol.spi.ExternalContainer allows to
+integrate containers which get started after the CDI container.
+Currently DeltaSpike provides:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>MockedJsf2TestContainer (integration with MyFaces-Test)</p>
+</li>
+</ul>
+</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