deltaspike-commits mailing list archives

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

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 21:02:15 2014
@@ -1 +1 @@
-1618730
+1618735

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 21:02:15 2014
@@ -833,69 +833,66 @@ that exception chain, unless it's explic
 <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>
 <p>First, create an Annotation with annotated with @javax.inject.Scope; Example:</p>
-<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>
+<div class="codehilite"><pre><span class="nd">@Scope</span>
+<span class="nd">@Retention</span><span class="o">(</span><span
class="n">RetentionPolicy</span><span class="o">.</span><span class="na">RUNTIME</span><span
class="o">)</span>
+<span class="nd">@Target</span><span class="o">({</span><span
class="n">ElementType</span><span class="o">.</span><span class="na">TYPE</span><span
class="o">,</span><span class="n">ElementType</span><span class="o">.</span><span
class="na">METHOD</span><span class="o">,</span><span class="n">ElementType</span><span
class="o">.</span><span class="na">FIELD</span><span class="o">})</span>
+<span class="kd">public</span> <span class="nd">@interface</span>
<span class="n">ACustomScope</span> <span class="o">{}</span>
 </pre></div>
 
 
 <p>Second, create an Extension to add the scope and a context for it. Example:</p>
-<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>
+<div class="codehilite"><pre><span class="kd">public</span> <span
class="kd">class</span> <span class="nc">ACustomScopeExtension</span>
<span class="kd">implements</span> <span class="n">Extension</span><span
class="o">,</span> <span class="n">Serializable</span> <span class="o">{</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>
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">addACustomScope</span><span class="o">(</span><span class="nd">@Observes</span>
<span class="kd">final</span> <span class="n">BeforeBeanDiscovery</span>
<span class="n">event</span><span class="o">)</span> <span class="o">{</span>
+        <span class="n">event</span><span class="o">.</span><span
class="na">addScope</span><span class="o">(</span><span class="n">ACustomScope</span><span
class="o">.</span><span class="na">class</span><span class="o">,</span>
<span class="kc">true</span><span class="o">,</span> <span class="kc">false</span><span
class="o">);</span>
+    <span class="o">}</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">registerACustomScopeContext</span><span class="o">(</span><span
class="nd">@Observes</span> <span class="kd">final</span> <span class="n">AfterBeanDiscovery</span>
<span class="n">event</span><span class="o">)</span> <span class="o">{</span>
+        <span class="n">event</span><span class="o">.</span><span
class="na">addContext</span><span class="o">(</span><span class="k">new</span>
<span class="n">ACustomScopeContext</span><span class="o">());</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
 <p>Implement a javax.enterprise.context.spi.Context interface to hold the javax.enterprise.inject.spi.Bean
instances according to your needs</p>
-<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>
+<div class="codehilite"><pre><span class="kd">public</span> <span
class="kd">class</span> <span class="nc">ACustomScopeContext</span> <span
class="kd">implements</span> <span class="n">Context</span><span class="o">,</span>
<span class="n">Serializable</span> <span class="o">{</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">// Get the scope type of the context object.</span>
+    <span class="kd">public</span> <span class="n">Class</span><span
class="o">&lt;?</span> <span class="kd">extends</span> <span class="n">Annotation</span><span
class="o">&gt;</span> <span class="n">getScope</span><span class="o">()</span>
<span class="o">{</span>
+        <span class="k">return</span> <span class="n">ACustomScope</span><span
class="o">.</span><span class="na">class</span><span class="o">;</span>
+    <span class="o">}</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="kd">public</span> <span class="o">&lt;</span><span
class="n">T</span><span class="o">&gt;</span> <span class="n">T</span>
<span class="n">get</span><span class="o">(</span><span class="n">Contextual</span><span
class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span>
<span class="n">contextual</span><span class="o">,</span> <span
class="n">CreationalContext</span><span class="o">&lt;</span><span
class="n">T</span><span class="o">&gt;</span> <span class="n">creationalContext</span><span
class="o">)</span> <span class="o">{</span>
+        <span class="n">Bean</span> <span class="n">bean</span> <span
class="o">=</span> <span class="o">(</span><span class="n">Bean</span><span
class="o">)</span> <span class="n">contextual</span><span class="o">;</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="k">if</span> <span class="o">(</span><span
class="n">somewhere</span><span class="o">.</span><span class="na">containsKey</span><span
class="o">(</span><span class="n">bean</span><span class="o">.</span><span
class="na">getName</span><span class="o">()))</span> <span class="o">{</span>
+            <span class="k">return</span> <span class="o">(</span><span
class="n">T</span><span class="o">)</span> <span class="n">somewhere</span><span
class="o">.</span><span class="na">get</span><span class="o">(</span><span
class="n">bean</span><span class="o">.</span><span class="na">getName</span><span
class="o">());</span>
+        <span class="o">}</span> <span class="k">else</span> <span
class="o">{</span>
+            <span class="n">T</span> <span class="n">t</span> <span
class="o">=</span> <span class="o">(</span><span class="n">T</span><span
class="o">)</span> <span class="n">bean</span><span class="o">.</span><span
class="na">create</span><span class="o">(</span><span class="n">creationalContext</span><span
class="o">);</span>
+            <span class="n">somewhere</span><span class="o">.</span><span
class="na">put</span><span class="o">(</span><span class="n">bean</span><span
class="o">.</span><span class="na">getName</span><span class="o">(),</span>
<span class="n">t</span><span class="o">);</span>
+            <span class="k">return</span> <span class="n">t</span><span
class="o">;</span>
+        <span class="o">}</span>
+    <span class="o">}</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="kd">public</span> <span class="o">&lt;</span><span
class="n">T</span><span class="o">&gt;</span> <span class="n">T</span>
<span class="n">get</span><span class="o">(</span><span class="n">Contextual</span><span
class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span>
<span class="n">contextual</span><span class="o">)</span> <span
class="o">{</span>
+        <span class="n">Bean</span> <span class="n">bean</span> <span
class="o">=</span> <span class="o">(</span><span class="n">Bean</span><span
class="o">)</span> <span class="n">contextual</span><span class="o">;</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="k">if</span> <span class="o">(</span><span
class="n">somewhere</span><span class="o">.</span><span class="na">containsKey</span><span
class="o">(</span><span class="n">bean</span><span class="o">.</span><span
class="na">getName</span><span class="o">()))</span> <span class="o">{</span>
+            <span class="k">return</span> <span class="o">(</span><span
class="n">T</span><span class="o">)</span> <span class="n">somewhere</span><span
class="o">.</span><span class="na">get</span><span class="o">(</span><span
class="n">bean</span><span class="o">.</span><span class="na">getName</span><span
class="o">());</span>
+        <span class="o">}</span> <span class="k">else</span> <span
class="o">{</span>
+            <span class="k">return</span> <span class="kc">null</span><span
class="o">;</span>
+        <span class="o">}</span>
+    <span class="o">}</span>
 
-  <span class="p">}</span>
+  <span class="c1">// Determines if the context object is active.</span>
+    <span class="kd">public</span> <span class="kt">boolean</span>
<span class="nf">isActive</span><span class="o">()</span> <span
class="o">{</span>
+        <span class="k">return</span> <span class="kc">true</span><span
class="o">;</span>
+    <span class="o">}</span>
+
+<span class="o">}</span>
 </pre></div>
 
 



Mime
View raw message