Author: buildbot
Date: Wed Feb  3 17:30:21 2016
New Revision: 979394

Log:
Staging update by buildbot for felix

Modified:
    websites/staging/felix/trunk/content/   (props changed)
    
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/guides/dm-lambda.html

Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Feb  3 17:30:21 2016
@@ -1 +1 @@
-1728309
+1728346

Modified: 
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/guides/dm-lambda.html
==============================================================================
--- 
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/guides/dm-lambda.html
 (original)
+++ 
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/guides/dm-lambda.html
 Wed Feb  3 17:30:21 2016
@@ -91,9 +91,11 @@ h2:hover > .headerlink, h3:hover > .head
 <p>Since the R7 version, a new dm-lambda library has been introduced in the DM 
distribution. This new library allows to programmatically declare OSGi 
components
 using a bit more fluent, concise and type-safe API that is based on Java8 
Lambda expressions and other goodies like method references.</p>
 <h2 id="principle">Principle<a class="headerlink" href="#principle" 
title="Permanent link">&para;</a></h2>
-<p>The new library is based on the <code>builder</code> design pattern applied 
to java8 lambdas. Basically, you call a chain of methods from a fluent 
<code>builder</code>, and at the end of the chain, you call
-<code>build()</code> which returns the actual DM objects that you already know 
from the original DM API. We'll see later that using lambdas you can then build 
the objects and add them to
-the DependencyManager class automatically.</p>
+<p>The new library is based on the <code>builder</code> design pattern applied 
to java8 lambdas. Basically, you call a chain of methods from a 
+fluent <code>builder</code>, and at the end of the chain, you call 
"<code>build()</code>" which returns the actual DM objects that you already 
know from 
+the original DM API. 
+We'll see later that using lambdas avoids the call to the last 
"<code>build</code>" method and adds the constructed DM Component into the 
+DependencyManager object automatically.</p>
 <p>The new API is provided by the 
<code>org.apache.felix.dependencymanager.lambda.jar</code> bundle. the 
following builders are currently supported:</p>
 <ul>
 <li>ComponentBuilder: it is used to build some instances of the 
org.apache.felix.dm.Component interface.</li>
@@ -109,12 +111,14 @@ the DependencyManager class automaticall
 <p>You can first instantiate builders using some of the convenient factory 
methods available from the DependencyManagerActivator class, which is the new 
base class
 for dm-lambda activators:</p>
 <div class="codehilite"><pre><span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.lambda.DependencyManagerActivator</span><span 
class="o">;</span>
+<span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.lambda.ComponentBuilder</span><span 
class="o">;</span>
 <span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.Component</span><span class="o">;</span>
 
 <span class="kd">public</span> <span class="kd">class</span> <span 
class="nc">Activator</span> <span class="kd">extends</span> <span 
class="n">DependencyManagerActivator</span> <span class="o">{</span>
     <span class="nd">@Override</span>
     <span class="kd">public</span> <span class="kt">void</span> <span 
class="nf">activate</span><span class="o">()</span> <span 
class="kd">throws</span> <span class="n">Exception</span> <span 
class="o">{</span>
-        <span class="n">Component</span> <span class="n">comp</span> <span 
class="o">=</span> <span class="n">component</span><span 
class="o">().</span><span class="na">impl</span><span class="o">(</span><span 
class="n">Hello</span><span class="o">.</span><span 
class="na">class</span><span class="o">).</span><span 
class="na">build</span><span class="o">();</span>
+        <span class="n">ComponentBuilder</span> <span class="n">builder</span> 
<span class="o">=</span> <span class="n">component</span><span 
class="o">();</span>
+        <span class="n">Component</span> <span class="n">comp</span> <span 
class="o">=</span> <span class="n">builder</span><span class="o">.</span><span 
class="na">impl</span><span class="o">(</span><span class="n">Hello</span><span 
class="o">.</span><span class="na">class</span><span class="o">).</span><span 
class="na">build</span><span class="o">();</span>
         <span class="n">DependencyManager</span> <span class="n">dm</span> 
<span class="o">=</span> <span class="n">getDM</span><span class="o">();</span>
         <span class="n">dm</span><span class="o">.</span><span 
class="na">add</span><span class="o">(</span><span class="n">comp</span><span 
class="o">);</span>
     <span class="o">}</span>
@@ -123,10 +127,25 @@ for dm-lambda activators:</p>
 
 
 <p>The <code>component()</code> method returns a <code>ComponentBuilder</code> 
and the call to <code>build</code> at the end of the call chain returns the 
actual DM Component object.</p>
-<p>Now, most of the time, in an Activator, you usually almost always create 
and immediately add the component to the <code>dm</code> object.
-So, in order to reduce the code size, you can also use a special overloaded 
factory method that accepts a lambda which takes as argument a
-<code>Consumer&lt;ComponentBuilder&gt;</code> parameter.
-So, the lambda has just to invoke the chain of necessary methods from the 
builder, without having to call <code>build</code> and add the returned 
Component to the <code>dm</code> object.</p>
+<p>Here is a shorter version:</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.lambda.DependencyManagerActivator</span><span 
class="o">;</span>
+<span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.Component</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span 
class="nc">Activator</span> <span class="kd">extends</span> <span 
class="n">DependencyManagerActivator</span> <span class="o">{</span>
+    <span class="nd">@Override</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span 
class="nf">activate</span><span class="o">()</span> <span 
class="kd">throws</span> <span class="n">Exception</span> <span 
class="o">{</span>
+        <span class="n">Component</span> <span class="n">comp</span> <span 
class="o">=</span> <span class="n">component</span><span 
class="o">().</span><span class="na">impl</span><span class="o">(</span><span 
class="n">Hello</span><span class="o">.</span><span 
class="na">class</span><span class="o">).</span><span 
class="na">build</span><span class="o">());</span>
+        <span class="n">getDM</span><span class="o">().</span><span 
class="na">add</span><span class="o">(</span><span class="n">comp</span><span 
class="o">);</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Now, most of the time, in an Activator you usually create a Component and 
immediately add it to the <code>dm</code> object.
+So, in order to reduce the code size, you can then use a special overloaded 
factory method that accepts a lambda which takes as 
+argument a <code>Consumer&lt;ComponentBuilder&gt;</code> parameter.
+So, the lambda has just to invoke the chain of necessary methods from the 
builder, without having to call the last "<code>build</code>" method. 
+The constructed Component is then automatically added to the <code>dm</code> 
object.</p>
 <p>The following is the same as above, using a 
<code>consumer&lt;ComponentBuilder&gt;</code> lambda expression:</p>
 <div class="codehilite"><pre><span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.lambda.DependencyManagerActivator</span><span 
class="o">;</span>
 <span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.lambda.ComponentBuilder</span><span 
class="o">;</span>
@@ -193,7 +212,7 @@ Such method accepts a <code>Consumer&lt;
 </pre></div>
 
 
-<h2 id="defining-service-dependency-components-callbacks">Defining Service 
Dependency Component's callbacks<a class="headerlink" 
href="#defining-service-dependency-components-callbacks" title="Permanent 
link">&para;</a></h2>
+<h2 id="service-dependency-component-callbacks">Service Dependency Component 
callbacks<a class="headerlink" href="#service-dependency-component-callbacks" 
title="Permanent link">&para;</a></h2>
 <p>By default, service dependencies are auto injected in class fields (you can 
configure the name of the class field where the dependency should be injected).
 But like in the current DM API, you can specify callbacks on the component 
implementation class using the "<code>cb</code>" 
<code>ServiceDependencyBuilder</code> method:</p>
 <div class="codehilite"><pre><span class="kn">import</span> <span 
class="nn">org.apache.felix.dm.lambda.DependencyManagerActivator</span><span 
class="o">;</span>
@@ -595,7 +614,7 @@ and the service is registered.</p>
 <p>Caution: if you are using a corporate http proxy, you have to fix the 
Activator in order to configure the ip addr and port number of your
 http proxy.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; 
text-align: right;">
-        Rev. 1728309 by pderop on Wed, 3 Feb 2016 13:41:34 +0000
+        Rev. 1728346 by pderop on Wed, 3 Feb 2016 17:29:51 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache 
Felix project


Reply via email to