You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by bu...@apache.org on 2013/09/30 10:19:41 UTC

svn commit: r880466 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.html

Author: buildbot
Date: Mon Sep 30 08:19:41 2013
New Revision: 880466

Log:
Staging update by buildbot for felix

Modified:
    websites/staging/felix/trunk/content/   (props changed)
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.html

Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Sep 30 08:19:41 2013
@@ -1 +1 @@
-1527482
+1527484

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.html Mon Sep 30 08:19:41 2013
@@ -840,27 +840,35 @@ public class HelloConsumer {
 </pre></div>
 
 
-<p>or <br />
-    :::xml
-    <requires field="m_log" optional="true" 
-        default-implementation=
-           "org.apache.felix.ipojo.example.default.MyLogService"/></p>
+<p>or  </p>
+<div class="codehilite"><pre><span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;m_log&quot;</span> <span class="na">optional=</span><span class="s">&quot;true&quot;</span> 
+    <span class="na">default-implementation=</span>
+       <span class="s">&quot;org.apache.felix.ipojo.example.default.MyLogService&quot;</span><span class="nt">/&gt;</span>
+</pre></div>
+
+
 <p>If the log service is not available, iPOJO creates an instance of the <code>org.apache.felix.ipojo.example.default.MyLogService</code>. This object is injected instead of the <code>Nullable</code> object. In the example, the default implementation can print messages on the <code>System.err</code>. In comparison, the <code>nullable</code> object would have done nothing.</p>
 <p>Finally, you can also instructs iPOJO to throw a runtime exception when there are no service providers available. This option is often use in combination with the <code>timeout</code> option, that delay the decision. To throw an exception, use the <code>exception</code> attribute specifying the exception class to use. It must be a subclass of <code>RuntimeException</code>. Obvisouly, you can use <code>java.lang.RuntimeException</code> directly.</p>
-<p>:::java
-  @Requires(optional=true, exception=NoServiceException.class)
-  private LogService m_log;</p>
+<div class="codehilite"><pre><span class="nd">@Requires</span><span class="o">(</span><span class="n">optional</span><span class="o">=</span><span class="kc">true</span><span class="o">,</span> <span class="n">exception</span><span class="o">=</span><span class="n">NoServiceException</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="kd">private</span> <span class="n">LogService</span> <span class="n">m_log</span><span class="o">;</span>
+</pre></div>
+
+
 <p>or   </p>
-<p>:::xml
-  <requires field="m_log" optional="true" 
-      exception=
-         "org.apache.felix.ipojo.example.default.NoServiceException"/></p>
+<div class="codehilite"><pre><span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;m_log&quot;</span> <span class="na">optional=</span><span class="s">&quot;true&quot;</span> 
+  <span class="na">exception=</span>
+     <span class="s">&quot;org.apache.felix.ipojo.example.default.NoServiceException&quot;</span><span class="nt">/&gt;</span>
+</pre></div>
+
+
 <h2 id="wait-for-service-the-timeout-option">Wait for service : the timeout option</h2>
 <p>For scalar optional dependencies injected inside fields or constructors, you may want to wait for a service to arrive before injecting a <em>stub</em> (<code>nullable</code>, <code>null</code>, <code>default-implementation</code> or <code>exception</code>). The <code>timeout</code> attribute let you specify the amount of time (in milliseconds) to wait. If there are still no services available when the timeout is reached, then the no service action is applied.</p>
 <p>In the following example, the <code>AuthenticationService</code> is essential, but also may be subjected to updates. When the service is not there, you don't want to fail immediately, but give it a chance to re-appear <em>soon</em>:</p>
-<p>:::java
-  @Requires(optional=true, exception=UpdateInProgessException.class, timeout=1000)
-  private AuthenticationService m_auth;</p>
+<div class="codehilite"><pre><span class="nd">@Requires</span><span class="o">(</span><span class="n">optional</span><span class="o">=</span><span class="kc">true</span><span class="o">,</span> <span class="n">exception</span><span class="o">=</span><span class="n">UpdateInProgessException</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1000</span><span class="o">)</span>
+<span class="kd">private</span> <span class="n">AuthenticationService</span> <span class="n">m_auth</span><span class="o">;</span>
+</pre></div>
+
+
 <h2 id="note-about-callbacks">Note about Callbacks</h2>
 <p>Dependency manages two type of callback: bind and unbind. A callback with a type "bind" is called each type that a service provider arrives and the binding is necessary. According to the cardinality of the dependency it means:</p>
 <ul>
@@ -893,7 +901,7 @@ public class HelloConsumer {
                 may be trademarks or registered trademarks of their respective owners.
                 </div>
                 <div class="timestamp span3 offset2">
-                Rev. 1527482 by clement on Mon, 30 Sep 2013 08:13:36 +0000
+                Rev. 1527484 by clement on Mon, 30 Sep 2013 08:19:33 +0000
                 </div>
             </div>
         </footer>