You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by bu...@apache.org on 2012/11/11 23:54:18 UTC

svn commit: r838004 - in /websites/staging/deltaspike/trunk/content: ./ deltaspike/documentation.html

Author: buildbot
Date: Sun Nov 11 22:54:16 2012
New Revision: 838004

Log:
Staging update by buildbot for deltaspike

Modified:
    websites/staging/deltaspike/trunk/content/   (props changed)
    websites/staging/deltaspike/trunk/content/deltaspike/documentation.html

Propchange: websites/staging/deltaspike/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sun Nov 11 22:54:16 2012
@@ -1 +1 @@
-1408124
+1408139

Modified: websites/staging/deltaspike/trunk/content/deltaspike/documentation.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/deltaspike/documentation.html (original)
+++ websites/staging/deltaspike/trunk/content/deltaspike/documentation.html Sun Nov 11 22:54:16 2012
@@ -77,18 +77,128 @@
               </div>
               <p><div class="toc">
 <ul>
-<li><a href="#get-your-shoes-with-deltaspike">Get your shoes with DeltaSpike</a></li>
+<li><a href="#with-java-ee6">With Java-EE6+</a></li>
+<li><a href="#with-java-ee5-or-servlet-containers">With Java-EE5 or Servlet Containers</a></li>
+<li><a href="#project-configuration-with-maven">Project-Configuration (with Maven)</a><ul>
+<li><a href="#configuration-of-deltaspike-core">Configuration of DeltaSpike-Core</a></li>
+</ul>
+</li>
+<li><a href="#project-configuration-getting-started-without-maven">Project-Configuration - Getting Started (without Maven)</a></li>
+<li><a href="#with-java-se">With Java-SE</a><ul>
+<li><a href="#add-the-deltaspike-container-ctrl-api">Add the DeltaSpike Container-Ctrl API</a></li>
+<li><a href="#add-a-cdi-container-container-ctrl-impl">Add a CDI container + Container-Ctrl Impl</a><ul>
+<li><a href="#for-apache-openwebbeans">... for Apache OpenWebBeans</a></li>
+<li><a href="#for-jboss-weld-ri">... for JBoss Weld (RI)</a></li>
+</ul>
+</li>
+<li><a href="#start-the-cdi-container">Start the CDI container</a></li>
+</ul>
+</li>
 <li><a href="#a-more-complex-case">A more complex case</a></li>
 <li><a href="#projects-features">Project's features</a></li>
 </ul>
 </div>
 <hr />
-<h1 id="get-your-shoes-with-deltaspike">Get your shoes with DeltaSpike</h1>
-<p>As a <a href="http://jcp.org/en/jsr/detail?id=299">CDI</a> container is not provided out of the box top of all Java runtime (Java-SE, Web Application Server - Apache Tomcat, Eclipse Jetty, ...),
-DeltaSpike will help you as it provides the tooling required to bootstrap a standalone container. Moreover it offers you the possibility to start with the CDI implementation
-of your choice (<a href="http://docs.jboss.org/weld/reference/1.1.5.Final/en-US/html/">JBoss Weld</a>, <a href="http://openwebbeans.apache.org">Apache OpenWebbeans</a>, <a href="http://openejb.apache.org">Apache OpenEJB</a>)
-as it uses the ServiceLoader of JDK to detect which implementation has been packaged in your project's classpath.</p>
-<p>To bootstrap a CDI container in your Java application, you just need to instantiate the CdiContainer and call the boot method.</p>
+<h1 id="with-java-ee6">With Java-EE6+</h1>
+<p>If you are using DeltaSpike in a Java-EE6 environment, you don't need to configure a CDI implementation explicitly because it's shipped with the container.</p>
+<h1 id="with-java-ee5-or-servlet-containers">With Java-EE5 or Servlet Containers</h1>
+<p>Java-EE5 application servers as well as pure servlet containers like Apache Tomcat don't provide a CDI implementation out-of-the-box. So don't forget to setup the CDI implementation of your choice.</p>
+<h1 id="project-configuration-with-maven">Project-Configuration (with Maven)</h1>
+<p><strong>Hint:</strong>
+In the listings below replace the placeholders for the version with the version of your choice or use:</p>
+<div class="codehilite"><pre><span class="nt">&lt;properties&gt;</span>
+    <span class="nt">&lt;deltaspike.version&gt;</span>incubating-0.4-SNAPSHOT<span class="nt">&lt;/deltaspike.version&gt;</span>
+<span class="nt">&lt;/properties&gt;</span>
+</pre></div>
+
+
+<h2 id="configuration-of-deltaspike-core">Configuration of DeltaSpike-Core</h2>
+<div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.deltaspike.core<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>deltaspike-core-api<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">deltaspike</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>compile<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+
+<span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.deltaspike.core<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>deltaspike-core-impl<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">deltaspike</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+
+
+<h1 id="project-configuration-getting-started-without-maven">Project-Configuration - Getting Started (without Maven)</h1>
+<p>You can manually download all JARs described above from the maven repository or you get <a href="source.html">the source-code</a> and <a href="build.html">build</a> DeltaSpike manually.</p>
+<h1 id="with-java-se">With Java-SE</h1>
+<p>Java-SE doesn't provide a CDI implementation out-of-the-box. So don't forget to add the CDI implementation of your choice.</p>
+<p><strong>Hint:</strong>
+In the listings below replace the placeholders for the version with the version of your choice or use:</p>
+<div class="codehilite"><pre><span class="nt">&lt;properties&gt;</span>
+    <span class="nt">&lt;deltaspike.version&gt;</span>incubating-0.4-SNAPSHOT<span class="nt">&lt;/deltaspike.version&gt;</span>
+    <span class="nt">&lt;owb.version&gt;</span>1.1.6<span class="nt">&lt;/owb.version&gt;</span>
+    <span class="nt">&lt;weld.version&gt;</span>1.1.9.Final<span class="nt">&lt;/weld.version&gt;</span>
+<span class="nt">&lt;/properties&gt;</span>
+</pre></div>
+
+
+<h2 id="add-the-deltaspike-container-ctrl-api">Add the DeltaSpike Container-Ctrl API</h2>
+<div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>deltaspike-cdictrl-api<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">deltaspike</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>compile<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+
+
+<h2 id="add-a-cdi-container-container-ctrl-impl">Add a CDI container + Container-Ctrl Impl</h2>
+<h3 id="for-apache-openwebbeans">... for Apache OpenWebBeans</h3>
+<div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.openwebbeans<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>openwebbeans-impl<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">owb</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+
+<span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.openwebbeans<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>openwebbeans-spi<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">owb</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>compile<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+
+<span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>deltaspike-cdictrl-owb<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">deltaspike</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+
+
+<h3 id="for-jboss-weld-ri">... for JBoss Weld (RI)</h3>
+<div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>deltaspike-cdictrl-weld<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">deltaspike</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+
+<span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.jboss.weld.se<span class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>weld-se<span class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">weld</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+
+
+<h2 id="start-the-cdi-container">Start the CDI container</h2>
+<p>DeltaSpike allows you to control a CDI container via a generic API and special support modules for 
+<a href="http://docs.jboss.org/weld/reference/1.1.5.Final/en-US/html/">JBoss Weld</a>, <a href="http://openwebbeans.apache.org">Apache OpenWebbeans</a> (and <a href="http://openejb.apache.org">Apache OpenEJB</a>).</p>
+<p>To bootstrap a CDI container in your Java application, you just need to instantiate the <code>CdiContainer and call the</code>#boot method.</p>
 <div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.deltaspike.cdise.api.CdiContainer</span><span class="o">;</span>
 <span class="kn">import</span> <span class="nn">org.apache.deltaspike.cdise.api.CdiContainerLoader</span><span class="o">;</span>
 
@@ -106,20 +216,40 @@ as it uses the ServiceLoader of JDK to d
 </pre></div>
 
 
-<p>When boot is called, the CdiContainer will scan the whole classpath for Beans and CDI extensions available.</p>
-<p>Note: Booting the container does <i>not</i> automatically start all CDI Contexts! Depending on the underlying CDI container you might need to invoke <code>getContextControl()
-and execute</code>ContextControl#startContext(Class)<code>or</code>ContextControl#startContexts()`.</p>
-<p>To inject a bean in this project, you should use the <code>BeanManagerProvider</code> or the <code>BeanProvider</code> like this</p>
-<div class="codehilite"><pre><span class="n">EchoService</span> <span class="n">defaultEchoService</span> <span class="o">=</span> <span class="n">BeanProvider</span><span class="o">.</span><span class="n">getContextualReference</span><span class="p">(</span><span class="n">DefaultEchoService</span><span class="o">.</span><span class="n">class</span><span class="p">,</span> <span class="n">false</span><span class="p">);</span>
+<p>When <code>#boot</code> is called, the <code>CdiContainer</code> will scan CDI enabled archives for beans and CDI extensions.</p>
+<p><strong>Note</strong>: Booting the container does <i>not</i> automatically start all CDI Contexts!</p>
+<p>Example for starting the application-context:</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.deltaspike.cdise.api.CdiContainer</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.deltaspike.cdise.api.CdiContainerLoader</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.deltaspike.cdise.api.ContextControl</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">javax.enterprise.context.ApplicationScoped</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">SimpleApp</span> <span class="o">{</span>
+    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
+
+        <span class="n">CdiContainer</span> <span class="n">CdiContainer</span> <span class="o">=</span> <span class="n">CdiContainerLoader</span><span class="o">.</span><span class="na">getCdiContainer</span><span class="o">();</span>
+        <span class="n">CdiContainer</span><span class="o">.</span><span class="na">boot</span><span class="o">();</span>
+
+        <span class="c1">// Starting the application-context allows to use @ApplicationScoped beans</span>
+        <span class="n">ContextControl</span> <span class="n">contextControl</span> <span class="o">=</span> <span class="n">cdiContainer</span><span class="o">.</span><span class="na">getContextControl</span><span class="o">();</span>
+        <span class="n">contextControl</span><span class="o">.</span><span class="na">startContext</span><span class="o">(</span><span class="n">ApplicationScoped</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
+
+        <span class="c1">// You can use CDI here</span>
+
+        <span class="n">CdiContainer</span><span class="o">.</span><span class="na">shutdown</span><span class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
-<p>When you have finish the job, simply call <code>shutdown()</code> to tell to the CDI container to destroy the beans instantiated</p>
-<p>Remarks :</p>
-<ul>
-<li>Java-EE5 : Java-EE5 application servers as well as pure servlet containers like Apache Tomcat don't provide a CDI implementation out-of-the-box. So don't forget to setup the CDI implementation of your choice.</li>
-<li>Java-EE6+ : If you are using DeltaSpike in a Java-EE6 environment, you don't need to configure a CDI implementation explicitly because it's shipped with the container.</li>
-</ul>
+<p>To resolve a bean of this project, you can use the <code>BeanProvider</code> provided by DeltaSpike.
+The following example shows how to resolve the a bean without qualifiers. It depends on the application if <code>EchoService</code> is a concrete implementation or just an interface. In case of an interface the corresponding implementation will be resolved.
+The resolved bean is a normal CDI bean which means you can use all CDI concepts like <code>@Inject</code> in the class (and you don't need further usages of <code>BeanProvider</code>).</p>
+<div class="codehilite"><pre><span class="n">EchoService</span> <span class="n">echoService</span> <span class="o">=</span> <span class="n">BeanProvider</span><span class="o">.</span><span class="na">getContextualReference</span><span class="o">(</span><span class="n">EchoService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
+</pre></div>
+
+
+<p>Before the application exits, you have to call <code>#shutdown</code> to destroy beans,... in a well-ordered fashion.</p>
 <h1 id="a-more-complex-case">A more complex case</h1>
 <p>TBD</p>
 <h1 id="projects-features">Project's features</h1>