deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r919742 - in /websites/staging/deltaspike/trunk/content: ./ core.html
Date Mon, 18 Aug 2014 20:58:41 GMT
Author: buildbot
Date: Mon Aug 18 20:58:41 2014
New Revision: 919742

Log:
Staging update by buildbot for deltaspike

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

Propchange: websites/staging/deltaspike/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Aug 18 20:58:41 2014
@@ -1 +1 @@
-1618729
+1618730

Modified: websites/staging/deltaspike/trunk/content/core.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/core.html (original)
+++ websites/staging/deltaspike/trunk/content/core.html Mon Aug 18 20:58:41 2014
@@ -832,75 +832,73 @@ that exception chain, unless it's explic
 <h3 id="groupedconversationscoped">@GroupedConversationScoped</h3>
 <h2 id="creating-a-custom-cdi-scope">Creating a custom CDI Scope</h2>
 <p>If you want to create a custom CDI scope to match your needs, you will need to follow
these steps:</p>
-<ol>
-<li>
 <p>First, create an Annotation with annotated with @javax.inject.Scope; Example:</p>
-<p>:::java
-  @Scope
-  @Retention(RetentionPolicy.RUNTIME)
-  @Target({ElementType.TYPE,ElementType.METHOD,ElementType.FIELD})
-  public @interface ACustomScope {}</p>
-</li>
-<li>
+<div class="codehilite"><pre>  <span class="o">:::</span><span
class="n">java</span>
+  <span class="err">@</span><span class="n">Scope</span>
+  <span class="err">@</span><span class="n">Retention</span><span
class="p">(</span><span class="n">RetentionPolicy</span><span class="p">.</span><span
class="n">RUNTIME</span><span class="p">)</span>
+  <span class="err">@</span><span class="n">Target</span><span
class="p">({</span><span class="n">ElementType</span><span class="p">.</span><span
class="n">TYPE</span><span class="p">,</span><span class="n">ElementType</span><span
class="p">.</span><span class="n">METHOD</span><span class="p">,</span><span
class="n">ElementType</span><span class="p">.</span><span class="n">FIELD</span><span
class="p">})</span>
+  <span class="n">public</span> <span class="err">@</span><span
class="n">interface</span> <span class="n">ACustomScope</span> <span
class="p">{}</span>
+</pre></div>
+
+
 <p>Second, create an Extension to add the scope and a context for it. Example:</p>
-<p>:::java  <br />
-  public class ACustomScopeExtension implements Extension, Serializable {</p>
-<div class="codehilite"><pre><span class="n">public</span> <span
class="n">void</span> <span class="n">addACustomScope</span><span
class="p">(@</span><span class="n">Observes</span> <span class="n">final</span>
<span class="n">BeforeBeanDiscovery</span> <span class="n">event</span><span
class="p">)</span> <span class="p">{</span>
-    <span class="n">event</span><span class="p">.</span><span
class="n">addScope</span><span class="p">(</span><span class="n">ACustomScope</span><span
class="p">.</span><span class="n">class</span><span class="p">,</span>
<span class="n">true</span><span class="p">,</span> <span class="n">false</span><span
class="p">);</span>
-<span class="p">}</span>
-
-<span class="n">public</span> <span class="n">void</span> <span
class="n">registerACustomScopeContext</span><span class="p">(@</span><span
class="n">Observes</span> <span class="n">final</span> <span class="n">AfterBeanDiscovery</span>
<span class="n">event</span><span class="p">)</span> <span class="p">{</span>
-    <span class="n">event</span><span class="p">.</span><span
class="n">addContext</span><span class="p">(</span><span class="n">new</span>
<span class="n">ACustomScopeContext</span><span class="p">());</span>
-<span class="p">}</span>
+<div class="codehilite"><pre>  <span class="p">:::</span><span
class="n">java</span>    
+  <span class="n">public</span> <span class="n">class</span> <span
class="n">ACustomScopeExtension</span> <span class="n">implements</span>
<span class="n">Extension</span><span class="p">,</span> <span
class="n">Serializable</span> <span class="p">{</span>
+
+    <span class="n">public</span> <span class="n">void</span> <span
class="n">addACustomScope</span><span class="p">(@</span><span class="n">Observes</span>
<span class="n">final</span> <span class="n">BeforeBeanDiscovery</span>
<span class="n">event</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">event</span><span class="p">.</span><span
class="n">addScope</span><span class="p">(</span><span class="n">ACustomScope</span><span
class="p">.</span><span class="n">class</span><span class="p">,</span>
<span class="n">true</span><span class="p">,</span> <span class="n">false</span><span
class="p">);</span>
+    <span class="p">}</span>
+
+    <span class="n">public</span> <span class="n">void</span> <span
class="n">registerACustomScopeContext</span><span class="p">(@</span><span
class="n">Observes</span> <span class="n">final</span> <span class="n">AfterBeanDiscovery</span>
<span class="n">event</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">event</span><span class="p">.</span><span
class="n">addContext</span><span class="p">(</span><span class="n">new</span>
<span class="n">ACustomScopeContext</span><span class="p">());</span>
+    <span class="p">}</span>
+  <span class="p">}</span>
 </pre></div>
 
 
-<p>}</p>
-</li>
-<li>
 <p>Implement a javax.enterprise.context.spi.Context interface to hold the javax.enterprise.inject.spi.Bean
instances according to your needs</p>
-<p>:::java
-  public class ACustomScopeContext implements Context, Serializable {</p>
-<div class="codehilite"><pre><span class="c1">// Get the scope type of
the context object.</span>
-<span class="n">public</span> <span class="n">Class</span><span
class="o">&lt;?</span> <span class="k">extends</span> <span class="n">Annotation</span><span
class="o">&gt;</span> <span class="n">getScope</span><span class="p">()</span>
<span class="p">{</span>
-    <span class="k">return</span> <span class="n">ACustomScope</span><span
class="p">.</span><span class="k">class</span><span class="p">;</span>
-<span class="p">}</span>
-
-<span class="c1">// Return an existing instance of certain contextual type or create
a new instance by calling</span>
-<span class="c1">// javax.enterprise.context.spi.Contextual.create(CreationalContext)
and return the new instance.</span>
-<span class="n">public</span> <span class="o">&lt;</span><span
class="no">T</span><span class="o">&gt;</span> <span class="no">T</span>
<span class="n">get</span><span class="p">(</span><span class="n">Contextual</span><span
class="o">&lt;</span><span class="no">T</span><span class="o">&gt;</span>
<span class="n">contextual</span><span class="p">,</span> <span
class="n">CreationalContext</span><span class="o">&lt;</span><span
class="no">T</span><span class="o">&gt;</span> <span class="n">creationalContext</span><span
class="p">)</span> <span class="p">{</span>
-    <span class="n">Bean</span> <span class="n">bean</span> <span
class="o">=</span> <span class="p">(</span><span class="n">Bean</span><span
class="p">)</span> <span class="n">contextual</span><span class="p">;</span>
-    <span class="c1">// you can store the bean somewhere</span>
-    <span class="k">if</span> <span class="p">(</span><span class="n">somewhere</span><span
class="p">.</span><span class="n">containsKey</span><span class="p">(</span><span
class="n">bean</span><span class="p">.</span><span class="n">getName</span><span
class="p">()))</span> <span class="p">{</span>
-        <span class="k">return</span> <span class="p">(</span><span
class="no">T</span><span class="p">)</span> <span class="n">somewhere</span><span
class="p">.</span><span class="n">get</span><span class="p">(</span><span
class="n">bean</span><span class="p">.</span><span class="n">getName</span><span
class="p">());</span>
-    <span class="p">}</span> <span class="k">else</span> <span
class="p">{</span>
-        <span class="no">T</span> <span class="n">t</span> <span
class="o">=</span> <span class="p">(</span><span class="no">T</span><span
class="p">)</span> <span class="n">bean</span><span class="p">.</span><span
class="n">create</span><span class="p">(</span><span class="n">creationalContext</span><span
class="p">);</span>
-        <span class="n">somewhere</span><span class="p">.</span><span
class="n">put</span><span class="p">(</span><span class="n">bean</span><span
class="p">.</span><span class="n">getName</span><span class="p">(),</span>
<span class="n">t</span><span class="p">);</span>
-        <span class="k">return</span> <span class="n">t</span><span
class="p">;</span>
-    <span class="p">}</span>
-<span class="p">}</span>
-
-<span class="c1">// Return an existing instance of a certain contextual type or a null
value.</span>
-<span class="n">public</span> <span class="o">&lt;</span><span
class="no">T</span><span class="o">&gt;</span> <span class="no">T</span>
<span class="n">get</span><span class="p">(</span><span class="n">Contextual</span><span
class="o">&lt;</span><span class="no">T</span><span class="o">&gt;</span>
<span class="n">contextual</span><span class="p">)</span> <span
class="p">{</span>
-    <span class="n">Bean</span> <span class="n">bean</span> <span
class="o">=</span> <span class="p">(</span><span class="n">Bean</span><span
class="p">)</span> <span class="n">contextual</span><span class="p">;</span>
-    <span class="c1">// you can store the bean somewhere</span>
-    <span class="k">if</span> <span class="p">(</span><span class="n">somewhere</span><span
class="p">.</span><span class="n">containsKey</span><span class="p">(</span><span
class="n">bean</span><span class="p">.</span><span class="n">getName</span><span
class="p">()))</span> <span class="p">{</span>
-        <span class="k">return</span> <span class="p">(</span><span
class="no">T</span><span class="p">)</span> <span class="n">somewhere</span><span
class="p">.</span><span class="n">get</span><span class="p">(</span><span
class="n">bean</span><span class="p">.</span><span class="n">getName</span><span
class="p">());</span>
-    <span class="p">}</span> <span class="k">else</span> <span
class="p">{</span>
-        <span class="k">return</span> <span class="k">null</span><span
class="p">;</span>
-    <span class="p">}</span>
-<span class="p">}</span>
-
-<span class="c1">// Determines if the context object is active.</span>
-<span class="n">public</span> <span class="n">boolean</span> <span
class="n">isActive</span><span class="p">()</span> <span class="p">{</span>
-    <span class="k">return</span> <span class="n">true</span><span
class="p">;</span>
-<span class="p">}</span>
+<div class="codehilite"><pre>  <span class="o">:::</span><span
class="nx">java</span>
+  <span class="kr">public</span> <span class="kr">class</span> <span
class="nx">ACustomScopeContext</span> <span class="kr">implements</span>
<span class="nx">Context</span><span class="p">,</span> <span class="nx">Serializable</span>
<span class="p">{</span>
+
+    <span class="c1">// Get the scope type of the context object.</span>
+    <span class="kr">public</span> <span class="nx">Class</span><span
class="cp">&lt;?</span> <span class="k">extends</span> <span class="nx">Annotation</span><span
class="o">&gt;</span> <span class="nx">getScope</span><span class="p">()</span>
<span class="p">{</span>
+        <span class="k">return</span> <span class="nx">ACustomScope</span><span
class="o">.</span><span class="nx">class</span><span class="p">;</span>
+    <span class="p">}</span>
+
+    <span class="c1">// Return an existing instance of certain contextual type or create
a new instance by calling</span>
+    <span class="c1">// javax.enterprise.context.spi.Contextual.create(CreationalContext)
and return the new instance.</span>
+    <span class="k">public</span> <span class="o">&lt;</span><span
class="nx">T</span><span class="o">&gt;</span> <span class="nx">T</span>
<span class="nx">get</span><span class="p">(</span><span class="nx">Contextual</span><span
class="o">&lt;</span><span class="nx">T</span><span class="o">&gt;</span>
<span class="nx">contextual</span><span class="p">,</span> <span
class="nx">CreationalContext</span><span class="o">&lt;</span><span
class="nx">T</span><span class="o">&gt;</span> <span class="nx">creationalContext</span><span
class="p">)</span> <span class="p">{</span>
+        <span class="nx">Bean</span> <span class="nx">bean</span>
<span class="o">=</span> <span class="p">(</span><span class="nx">Bean</span><span
class="p">)</span> <span class="nx">contextual</span><span class="p">;</span>
+        <span class="c1">// you can store the bean somewhere</span>
+        <span class="k">if</span> <span class="p">(</span><span
class="nx">somewhere</span><span class="o">.</span><span class="nx">containsKey</span><span
class="p">(</span><span class="nx">bean</span><span class="o">.</span><span
class="nx">getName</span><span class="p">()))</span> <span class="p">{</span>
+            <span class="k">return</span> <span class="p">(</span><span
class="nx">T</span><span class="p">)</span> <span class="nx">somewhere</span><span
class="o">.</span><span class="nx">get</span><span class="p">(</span><span
class="nx">bean</span><span class="o">.</span><span class="nx">getName</span><span
class="p">());</span>
+        <span class="p">}</span> <span class="k">else</span> <span
class="p">{</span>
+            <span class="nx">T</span> <span class="nx">t</span> <span
class="o">=</span> <span class="p">(</span><span class="nx">T</span><span
class="p">)</span> <span class="nx">bean</span><span class="o">.</span><span
class="nx">create</span><span class="p">(</span><span class="nx">creationalContext</span><span
class="p">);</span>
+            <span class="nx">somewhere</span><span class="o">.</span><span
class="nx">put</span><span class="p">(</span><span class="nx">bean</span><span
class="o">.</span><span class="nx">getName</span><span class="p">(),</span>
<span class="nx">t</span><span class="p">);</span>
+            <span class="k">return</span> <span class="nx">t</span><span
class="p">;</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+
+    <span class="c1">// Return an existing instance of a certain contextual type or
a null value.</span>
+    <span class="k">public</span> <span class="o">&lt;</span><span
class="nx">T</span><span class="o">&gt;</span> <span class="nx">T</span>
<span class="nx">get</span><span class="p">(</span><span class="nx">Contextual</span><span
class="o">&lt;</span><span class="nx">T</span><span class="o">&gt;</span>
<span class="nx">contextual</span><span class="p">)</span> <span
class="p">{</span>
+        <span class="nx">Bean</span> <span class="nx">bean</span>
<span class="o">=</span> <span class="p">(</span><span class="nx">Bean</span><span
class="p">)</span> <span class="nx">contextual</span><span class="p">;</span>
+        <span class="c1">// you can store the bean somewhere</span>
+        <span class="k">if</span> <span class="p">(</span><span
class="nx">somewhere</span><span class="o">.</span><span class="nx">containsKey</span><span
class="p">(</span><span class="nx">bean</span><span class="o">.</span><span
class="nx">getName</span><span class="p">()))</span> <span class="p">{</span>
+            <span class="k">return</span> <span class="p">(</span><span
class="nx">T</span><span class="p">)</span> <span class="nx">somewhere</span><span
class="o">.</span><span class="nx">get</span><span class="p">(</span><span
class="nx">bean</span><span class="o">.</span><span class="nx">getName</span><span
class="p">());</span>
+        <span class="p">}</span> <span class="k">else</span> <span
class="p">{</span>
+            <span class="k">return</span> <span class="k">null</span><span
class="p">;</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+
+    <span class="c1">// Determines if the context object is active.</span>
+    <span class="k">public</span> <span class="nx">boolean</span>
<span class="nx">isActive</span><span class="p">()</span> <span
class="p">{</span>
+        <span class="k">return</span> <span class="k">true</span><span
class="p">;</span>
+    <span class="p">}</span>
+
+  <span class="p">}</span>
 </pre></div>
 
 
-<p>}</p>
-</li>
-</ol>
 <h2 id="deactivatable">Deactivatable</h2>
 <p>DeltaSpike allows you to deactivate its own Extensions. You just need to implement
your <a href="spi.html#classdeactivator">ClassDeactivator</a>.</p>
 <p>The ClassDeactivator should be resolved by any ConfigSource using the key <code>org.apache.deltaspike.core.spi.activation.ClassDeactivator</code>.
For example, we can disable SecurityExtension having the following class:</p>



Mime
View raw message