felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r980846 [2/2] - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-dependency-manager/guides/dm-lambda.html
Date Sat, 20 Feb 2016 21:54:04 GMT
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 Sat Feb 20 21:54:03 2016
@@ -89,24 +89,92 @@ h2:hover > .headerlink, h3:hover > .head
 }
 h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
 <hr />
+<p><strong>Welcome to Felix Dependency Manager Lambda.</strong></p>
+<h2 id="introduction">Introduction<a class="headerlink" href="#introduction" title="Permanent link">&para;</a></h2>
 <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>
-<p>(Please notice that using the dm-lambda library requires the usage of a recent Java8 jvm (the library has been tested with java version "1.8.0_71").</p>
-<h2 id="principle">Principle<a class="headerlink" href="#principle" title="Permanent link">&para;</a></h2>
+using a new style based on java8 lambda expressions and other goodies like method references.</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>
+We'll see later that using lambdas avoids to call the last "<code>build</code>" method and allows to automatically add the constructed DM Component into the 
+DependencyManager object.</p>
+<p>Please notice that using the dm-lambda library requires the usage of a recent Java8 jvm (the library has been tested with java version "1.8.0_71").</p>
+<h2 id="comparing-two-activators-using-old-and-new-api">Comparing two activators using old and new API:<a class="headerlink" href="#comparing-two-activators-using-old-and-new-api" title="Permanent link">&para;</a></h2>
+<p>Before presenting the new API, let's get a jump start and dive into a comparison between the old and new API: assume we have a <code>ServiceConsumer</code> which depends on the following services:</p>
 <ul>
-<li>ComponentBuilder: it is used to build some instances of the org.apache.felix.dm.Component interface.</li>
-<li>ServiceDependencyBuilder: builds some instances of org.apache.felix.dm.ServiceDependency.</li>
-<li>ConfigurationDependencyBuiler: builds some instances of org.apache.felix.dm.ConfigurationDependency.</li>
-<li>BundleAdapterBuilder: builds some DM bundle adapters.</li>
-<li>ServiceAdapterBuilder.java: builds some instances of DM service adapters.</li>
-<li>FactoryPidAdapterBuilder: builds some instances of DM factory pid adapters.</li>
-<li>FutureDependencyBuilder: it's a new feature, allowing to "wait for" an asynchronous event represented by a standard jdk8 <code>CompletableFuture</code> object.</li>
+<li>a required dependency on <code>ServiceProvider</code> service  with a "<code>(p1=v1)</code>" filter. The dependency is injected in the "<code>ServiceConsumer.setProvider()</code>" method.</li>
+<li>a Configuration with pid="<code>org.apache.felix.dm.lambda.samples.hello.ServiceConsumer</code>".</li>
+</ul>
+<p>Now assume we have <code>ServiceProvider</code> provided with p1="v1" and p2=123 service properties; and the provider also depends on:</p>
+<ul>
+<li>a required <code>LogService</code> service (injected in class fields).</li>
+<li>a required <code>EventAdmin</code> service  (injected in class fields).</li>
+</ul>
+<p>Then we have the following typical Activator (we define both components in the same Activator for simplicity):</p>
+<div class="codehilite"><pre><span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">felix</span><span class="p">.</span><span class="n">dm</span><span class="p">.</span><span class="n">DependencyActivatorBase</span><span class="p">;</span>
+<span class="p">...</span>
+
+<span class="p">:::</span><span class="n">java</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">Activator</span> <span class="n">extends</span> <span class="n">DependencyActivatorBase</span> <span class="p">{</span>
+    <span class="p">@</span><span class="n">Override</span>
+    <span class="n">public</span> <span class="n">void</span> <span class="n">init</span><span class="p">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="p">)</span> <span class="n">throws</span> <span class="n">Exception</span> <span class="p">{</span>
+        <span class="o">//</span> <span class="n">Declare</span> <span class="n">our</span> <span class="n">Consumer</span> <span class="n">component</span>
+
+        <span class="n">Component</span> <span class="n">consumer</span> <span class="p">=</span> <span class="n">dm</span><span class="p">.</span><span class="n">createComponent</span><span class="p">()</span>
+            <span class="p">.</span><span class="n">setImplementation</span><span class="p">(</span><span class="n">ServiceConsumer</span><span class="p">.</span><span class="n">class</span><span class="p">)</span>
+            <span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">createServiceDependency</span><span class="p">().</span><span class="n">setService</span><span class="p">(</span><span class="n">ServiceProvider</span><span class="p">.</span><span class="n">class</span><span class="p">,</span> &quot;<span class="p">(</span><span class="n">p1</span><span class="p">=</span><span class="n">v1</span><span class="p">)</span>&quot;<span class="p">).</span><span class="n">setRequired</span><span class="p">(</span><span class="n">true</span><span class="p">).</span><span class="n">setCallbacks</span><span class="p">(</span>&quot;<span class="n">setProvider</span>&quot;<span class="p">,</span> <span class="n">null</span><span class="p">))</span>
+            <span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">createConfigurationDependency</span><span class="p">().</span><span class="n">setPid</span><span class="p">(</span><span class="n">ServiceConsumer</span><span class="p">.</span><span class="n">class</span><span class="p">.</span><span class="n">getName</span><span class="p">()));</span>
+        <span class="n">dm</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">consumer</span><span class="p">);</span>
+
+       <span class="o">//</span> <span class="n">Declare</span> <span class="n">our</span> <span class="n">ServiceProvider</span> <span class="n">service</span> <span class="n">component</span>
+
+       <span class="n">Properties</span> <span class="k">properties</span> <span class="p">=</span> <span class="n">new</span> <span class="n">Properties</span><span class="p">();</span>
+       <span class="n">Properties</span><span class="p">.</span><span class="n">put</span><span class="p">(</span>&quot;<span class="n">p1</span>&quot;<span class="p">,</span> &quot;<span class="n">v1</span>&quot;<span class="p">);</span>
+       <span class="k">properties</span><span class="p">.</span><span class="n">put</span><span class="p">(</span>&quot;<span class="n">p2</span>&quot;<span class="p">,</span> 123<span class="p">);</span>
+       <span class="n">Component</span> <span class="n">provider</span> <span class="p">=</span> <span class="n">dm</span><span class="p">.</span><span class="n">createComponent</span><span class="p">()</span>
+           <span class="p">.</span><span class="n">setImplementation</span><span class="p">(</span><span class="n">ServiceProviderImpl</span><span class="p">.</span><span class="n">class</span><span class="p">)</span>
+           <span class="p">.</span><span class="n">setInterface</span><span class="p">(</span><span class="n">ServiceProvider</span><span class="p">.</span><span class="n">class</span><span class="p">.</span><span class="n">getName</span><span class="p">(),</span> <span class="k">properties</span><span class="p">)</span>
+           <span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">createServiceDependency</span><span class="p">().</span><span class="n">setService</span><span class="p">(</span><span class="n">LogService</span><span class="p">.</span><span class="n">class</span><span class="p">).</span><span class="n">setRequired</span><span class="p">(</span><span class="n">true</span><span class="p">))</span>
+           <span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">createServiceDependency</span><span class="p">().</span><span class="n">setService</span><span class="p">(</span><span class="n">EventAdmin</span><span class="p">.</span><span class="n">class</span><span class="p">,</span> <span class="n">null</span><span class="p">).</span><span class="n">setRequired</span><span class="p">(</span><span class="n">true</span><span class="p">));</span>
+       <span class="n">dm</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">provider</span><span class="p">);</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>Now, let's rework the above example, using the new dm-lambda API:</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="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">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
+        <span class="c1">// Declare our Consumer component</span>
+
+        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">ServiceConsumer</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+            <span class="o">.</span><span class="na">withSvc</span><span class="o">(</span><span class="n">ServiceProvider</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">filter</span><span class="o">(</span><span class="s">&quot;(p1=v1)&quot;</span><span class="o">).</span><span class="na">add</span><span class="o">(</span><span class="nl">ServiceConsumer:</span><span class="o">:</span><span class="n">setProvider</span><span class="o">))</span>
+            <span class="o">.</span><span class="na">withCnf</span><span class="o">(</span><span class="n">ServiceConsumer</span><span class="o">.</span><span class="na">class</span><span class="o">.</span><span class="na">getName</span><span class="o">()));</span>
+
+        <span class="c1">// Declare our ServiceProvider service component:</span>
+
+        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">ServiceProviderImpl</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+            <span class="o">.</span><span class="na">provides</span><span class="o">(</span><span class="n">ServiceProvider</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">p1</span> <span class="o">-&gt;</span> <span class="s">&quot;v1&quot;</span><span class="o">,</span> <span class="n">p2</span> <span class="o">-&gt;</span> <span class="mi">123</span><span class="o">)</span>
+            <span class="o">.</span><span class="na">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">EventAdmin</span><span class="o">.</span><span class="na">class</span><span class="o">));</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>(all dependencies are required by default, if they are not explicitly declared as optional or required).</p>
+<h1 id="principle">Principle<a class="headerlink" href="#principle" title="Permanent link">&para;</a></h1>
+<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 org.apache.felix.dm.Component from original DM API.</li>
+<li>ServiceDependencyBuilder: builds org.apache.felix.dm.ServiceDependency from original DM API.</li>
+<li>ConfigurationDependencyBuiler: builds org.apache.felix.dm.ConfigurationDependency from original DM API.</li>
+<li>BundleAdapterBuilder: builds a bundle adapter component from the original DM API.</li>
+<li>ServiceAdapterBuilder.java: builds a DM service adapter from the original DM API.</li>
+<li>FactoryPidAdapterBuilder: builds a DM factory pid adapter from the original DM API.</li>
+<li>FutureDependencyBuilder: it's a new feature allowing to "wait for" an asynchronous event represented by a standard jdk8 <code>CompletableFuture</code> object.</li>
 </ul>
 <p>(There is currently no builders for DM ResourceDependency and ResourceAdapter objects, but they will be supported soon).</p>
 <p>There are two ways to use these builders:</p>
@@ -118,10 +186,9 @@ for dm-lambda activators:</p>
 
 <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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</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>
 <span class="o">}</span>
@@ -135,9 +202,9 @@ for dm-lambda activators:</p>
 
 <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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="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>
 <span class="o">}</span>
 </pre></div>
@@ -154,38 +221,36 @@ The constructed Component is then automa
 
 <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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">((</span><span class="n">ComponentBuilder</span> <span class="n">comp</span><span class="o">)</span> <span class="o">-&gt;</span> <span class="n">comp</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="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
-<p>And here is a more concise version where the type of the lambda parameter is not declared:</p>
+<p>And to reduce the "code ceremony", here is a more concise version where the type of the lambda parameter is not declared:</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="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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
-<h2 id="javadoc">Javadoc<a class="headerlink" href="#javadoc" title="Permanent link">&para;</a></h2>
-<p>You can find the javadoc for the new Dependency Manager Lambda library <a href="../../../../apidocs/">here</a>.</p>
 <h2 id="adding-service-dependencies">Adding service dependencies<a class="headerlink" href="#adding-service-dependencies" title="Permanent link">&para;</a></h2>
-<p>Service Dependencies, unlike in the original DM API, are required by default, and you can add a dependency using the <code>withSrv</code> methods available from the ComponentBuilder interface.
+<p>You can add a dependency using the <code>withSvc</code> methods available from the ComponentBuilder interface.
 Such method accepts a <code>Consumer&lt;ServiceDependencyBuilder&gt;</code> lambda expression, which may then configure the dependency using a chain of method calls (filter/callbacks,autoconfig, etc ...):</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.ServiceDependencyBuilder</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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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="o">.</span><span class="na">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="o">(</span><span class="n">ServiceDependencyBuilder</span> <span class="n">srv</span><span class="o">)</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">filter</span><span class="o">(</span><span class="s">&quot;(vendor=apache)&quot;</span><span class="o">)));</span>
+            <span class="o">.</span><span class="na">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="o">(</span><span class="n">ServiceDependencyBuilder</span> <span class="n">srv</span><span class="o">)</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">filter</span><span class="o">(</span><span class="s">&quot;(vendor=apache)&quot;</span><span class="o">)));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
@@ -196,65 +261,52 @@ Such method accepts a <code>Consumer&lt;
 
 <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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">filter</span><span class="o">(</span><span class="s">&quot;(vendor=apache)&quot;</span><span class="o">)));</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">filter</span><span class="o">(</span><span class="s">&quot;(vendor=apache)&quot;</span><span class="o">)));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
-<p>If you depend on multiple required services (without filters), you can declare the services in one shot like this:</p>
+<p>If you depend on multiple services (without filters), you can declare the services in one shot like this
+(the dependencies will be injected in compatible class fields, by reflection):</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="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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
         <span class="c1">// using a varargs of service dependencies ...</span>
-        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">EventAdmin</span><span class="o">.</span><span class="na">class</span><span class="o">));</span> 
+        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">EventAdmin</span><span class="o">.</span><span class="na">class</span><span class="o">));</span> 
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
-<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>
+<p>When you want to inject a service in a class field, but using a filter, you can also define a one-liner 
+dependency that is not needing a ServiceDependencyBuilder lambda:</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="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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">cb</span><span class="o">(</span><span class="s">&quot;setLog&quot;</span><span class="o">)));</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
+        <span class="c1">// using a varargs of service dependencies ...</span>
+        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;(vendor=apache)&quot;</span><span class="o">));</span> 
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
-<p>The <code>cb</code> method accepts a varargs of strings (up to 4 method names):</p>
-<ol>
-<li>when using one argument, it is used as the <code>add</code> callback.</li>
-<li>when using two arguments, the first arg is used as the <code>add</code> callback, and the second one as the <code>remove</code> callback.</li>
-<li>when using three arguments, the first arg is used as the <code>add</code> callback, the second one as the <code>change</code> callback, and the third one as the <code>remove</code> callback.</li>
-<li>when using four arguments, the first arg is used as the <code>add</code> callback, the second one as the <code>change</code> callback, the third one as the <code>remove</code> callback, and the last one as the <code>swap</code> callback.</li>
-</ol>
-<p>The add/change/remove callbacks accept the following kind of method signatures ("S" represents the type of the service dependency):</p>
-<div class="codehilite"><pre><span class="n">method</span><span class="p">(</span><span class="n">S</span> <span class="n">service</span><span class="p">)</span>
-<span class="n">method</span><span class="p">(</span><span class="n">S</span> <span class="n">service</span><span class="p">,</span> <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">serviceProperties</span><span class="p">)</span>
-<span class="n">method</span><span class="p">(</span><span class="n">S</span> <span class="n">service</span><span class="p">,</span> <span class="n">Dictionary</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">serviceProperties</span><span class="p">)</span>
-<span class="n">method</span><span class="p">(</span><span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">serviceRef</span><span class="p">,</span> <span class="n">S</span> <span class="n">service</span><span class="p">),</span>
-<span class="n">method</span><span class="p">(</span><span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">serviceRef</span><span class="p">)</span>
-<span class="n">method</span><span class="p">(</span><span class="n">Component</span> <span class="n">serviceComponent</span><span class="p">)</span>
-<span class="n">method</span><span class="p">(</span><span class="n">Component</span> <span class="n">serviceComponent</span><span class="p">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">serviceRef</span><span class="p">)</span>
-<span class="n">method</span><span class="p">(</span><span class="n">Component</span> <span class="n">serviceComponent</span><span class="p">,</span> <span class="n">S</span> <span class="n">service</span><span class="p">)</span> 
-<span class="n">method</span><span class="p">(</span><span class="n">Component</span> <span class="n">serviceComponent</span><span class="p">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">serviceRef</span><span class="p">,</span> <span class="n">S</span> <span class="n">service</span><span class="p">)</span>
-</pre></div>
-
+<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>add/change/remove/swap</code>" <code>ServiceDependencyBuilder</code> methods:</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.felix.dm.lambda.DependencyManagerActivator</span><span class="o">;</span>
 
-<p>And the "swap" callbacks accepts the following method signatures:</p>
-<div class="codehilite"><pre><span class="n">swapMethod</span><span class="p">(</span><span class="n">S</span> <span class="n">oldService</span><span class="p">,</span> <span class="n">S</span> <span class="n">newService</span><span class="p">)</span>
-<span class="n">swapMethod</span><span class="p">(</span><span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">oldRef</span><span class="p">,</span> <span class="n">S</span> <span class="n">old</span><span class="p">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">newRef</span><span class="p">,</span> <span class="n">S</span> <span class="n">newService</span><span class="p">)</span>
-<span class="n">swapMethod</span><span class="p">(</span><span class="n">Component</span> <span class="n">component</span><span class="p">,</span> <span class="n">S</span> <span class="n">oldService</span><span class="p">,</span> <span class="n">S</span> <span class="n">newService</span><span class="p">)</span>
-<span class="n">swapMethod</span><span class="p">(</span><span class="n">Component</span> <span class="n">component</span><span class="p">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">oldRef</span><span class="p">,</span> <span class="n">S</span> <span class="n">old</span><span class="p">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">newRef</span><span class="p">,</span> <span class="n">S</span> <span class="n">newService</span><span class="p">)</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">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;setLog&quot;</span><span class="o">)));</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
@@ -263,8 +315,8 @@ But like in the current DM API, you can
 
 <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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">cb</span><span class="o">(</span><span class="nl">Hello:</span><span class="o">:</span><span class="n">setLog</span><span class="o">)));</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="nl">Hello:</span><span class="o">:</span><span class="n">setLog</span><span class="o">)));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
@@ -275,24 +327,42 @@ But like in the current DM API, you can
 
 <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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">cb</span><span class="o">(</span><span class="nl">Hello:</span><span class="o">:</span><span class="n">setLog</span><span class="o">,</span> <span class="nl">Hello:</span><span class="o">:</span><span class="n">unsetLog</span><span class="o">)));</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="nl">Hello:</span><span class="o">:</span><span class="n">setLog</span><span class="o">).</span><span class="na">remove</span><span class="o">(</span><span class="nl">Hello:</span><span class="o">:</span><span class="n">unsetLog</span><span class="o">)));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
+<p>The following callback methods signatures are supported when using method references:</p>
+<p>For add/change/remove method references:</p>
+<div class="codehilite"><pre><span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">service</span><span class="o">)</span>
+<span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">service</span><span class="o">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">serviceRef</span><span class="o">),</span>
+<span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">service</span><span class="o">,</span> <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">serviceProperties</span><span class="o">)</span>
+<span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">service</span><span class="o">,</span> <span class="n">Dictionary</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">serviceProperties</span><span class="o">)</span>
+<span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">service</span><span class="o">,</span> <span class="n">Component</span> <span class="n">serviceComponent</span><span class="o">)</span>
+<span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">service</span><span class="o">,</span> <span class="n">Component</span> <span class="n">serviceComponent</span><span class="o">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">serviceRef</span><span class="o">)</span>
+</pre></div>
+
+
+<p>and for swap method references:</p>
+<div class="codehilite"><pre><span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">oldService</span><span class="o">,</span> <span class="n">S</span> <span class="n">newService</span><span class="o">)</span>
+<span class="n">method</span><span class="o">(</span><span class="n">S</span> <span class="n">oldService</span><span class="o">,</span> <span class="n">S</span> <span class="n">newService</span><span class="o">,</span> <span class="n">Component</span> <span class="n">component</span><span class="o">))</span>
+<span class="n">method</span><span class="o">(</span><span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">oldRef</span><span class="o">,</span> <span class="n">S</span> <span class="n">old</span><span class="o">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">newRef</span><span class="o">,</span> <span class="n">S</span> <span class="n">newService</span><span class="o">)</span>
+<span class="n">method</span><span class="o">(</span><span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">oldRef</span><span class="o">,</span> <span class="n">S</span> <span class="n">old</span><span class="o">,</span> <span class="n">ServiceReference</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span> <span class="n">newRef</span><span class="o">,</span> <span class="n">S</span> <span class="n">newService</span><span class="o">,</span> <span class="n">Component</span> <span class="n">component</span><span class="o">)</span>
+</pre></div>
+
+
 <h2 id="defining-service-dependency-object-instance-callback">Defining Service Dependency Object instance callback<a class="headerlink" href="#defining-service-dependency-object-instance-callback" title="Permanent link">&para;</a></h2>
-<p>Sometimes, you want to inject the dependency to a seperate object that is not part of the component implementation classes.
-In this case, you can use the "<code>cbi</code>" method (which stands for "<code>callback instance</code>").</p>
-<p>For example, the following example injects a dependency in a DependencyHandler instance:</p>
+<p>Sometimes, you want to inject the dependency to a separate object that is not part of the component implementation classes.
+For example, the following example injects a dependency in a DependencyHandler instance:</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="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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
         <span class="n">DependencyHandler</span> <span class="n">depHandler</span> <span class="o">=</span> <span class="k">new</span> <span class="n">DependencyHandler</span><span class="o">();</span>
-        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">cbi</span><span class="o">(</span><span class="n">depHandler</span><span class="o">,</span> <span class="s">&quot;setLog&quot;</span><span class="o">)));</span>
+        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">depHandler</span><span class="o">,</span> <span class="s">&quot;setLog&quot;</span><span class="o">)));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
@@ -303,9 +373,9 @@ In this case, you can use the "<code>cbi
 
 <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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
         <span class="n">DependencyHandler</span> <span class="n">depHandler</span> <span class="o">=</span> <span class="k">new</span> <span class="n">DependencyHandler</span><span class="o">();</span>
-        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">cbi</span><span class="o">(</span><span class="nl">depHandler:</span><span class="o">:</span><span class="n">setLog</span><span class="o">)));</span>
+        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="nl">depHandler:</span><span class="o">:</span><span class="n">setLog</span><span class="o">)));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
@@ -316,9 +386,9 @@ In this case, you can use the "<code>cbi
 
 <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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
         <span class="n">DependencyHandler</span> <span class="n">depHandler</span> <span class="o">=</span> <span class="k">new</span> <span class="n">DependencyHandler</span><span class="o">();</span>
-        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">cb</span><span class="o">(</span><span class="nl">Hello:</span><span class="o">:</span><span class="n">setLog</span><span class="o">).</span><span class="na">cbi</span><span class="o">(</span><span class="nl">depHandler:</span><span class="o">:</span><span class="n">setLog</span><span class="o">)));</span>
+        <span class="n">component</span><span class="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">srv</span> <span class="o">-&gt;</span> <span class="n">srv</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="nl">Hello:</span><span class="o">:</span><span class="n">setLog</span><span class="o">).</span><span class="na">add</span><span class="o">(</span><span class="nl">depHandler:</span><span class="o">:</span><span class="n">setLog</span><span class="o">)));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
@@ -331,35 +401,114 @@ In this case, you can use the "<code>cbi
 
 <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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">provides</span><span class="o">(</span><span class="n">HelloService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;p1&quot;</span><span class="o">,</span> <span class="s">&quot;v1&quot;</span><span class="o">,</span> <span class="s">&quot;p2&quot;</span><span class="o">,</span> <span class="mi">123</span><span class="o">));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
-<p>or if you build your program using the <code>-parameters</code> option, you can also use the "<code>FluentProperty</code>" lambda that allows to declare
+<p>or if you build your application using the <code>-parameters</code> javac option, you can also use the "<code>FluentProperty</code>" lambda that allows to declare
 service properties as a suite of "<code>key -&gt; value</code>" lambdas, like this:</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="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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</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">provides</span><span class="o">(</span><span class="n">HelloService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">p1</span> <span class="o">-&gt;</span> <span class="s">&quot;v1&quot;</span><span class="o">,</span> <span class="n">p2</span> <span class="o">-&gt;</span> <span class="mi">123</span><span class="o">));</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
+<h2 id="depending-on-a-configuration">Depending on a configuration.<a class="headerlink" href="#depending-on-a-configuration" title="Permanent link">&para;</a></h2>
+<p>Configuration dependency can be defined using the "<code>withCnf</code>" ComponentBuilder method.</p>
+<p>Two families of callbacks are supported:</p>
+<ul>
+<li>reflection based callbacks: you specify a callback method name</li>
+<li>method reference callbacks: you specify a java8 method reference</li>
+</ul>
+<p>Callbacks may accept a Dictionary, a Component, or a user defined configuration type interface. If you only specify a pid, by default the callback method name is assumed to be "updated".</p>
+<p>Configuration types are a new feature that allows you to specify an interface that is implemented by DM and such interface is then injected to your callback instead of the actual Dictionary. Using such configuration interface provides a way for creating type-safe configurations from a actual Dictionary that is normally injected by Dependency Manager. The callback accepts in argument an interface that you have to provide, and DM will inject a proxy that converts method calls from your configuration-type to lookups in the actual map or dictionary. The results of these lookups are then converted to the expected return type of the invoked configuration method.
+As proxies are injected, no implementations of the desired configuration-type are necessary!</p>
+<p>The lookups performed are based on the name of the method called on the configuration type. The method names are "mangled" to the following form: [lower case letter] [any valid character]*. Method names starting with get or is (JavaBean convention) are stripped from these prefixes. For example: given a dictionary with the key "foo" can be accessed from a configuration-type using the following method names: foo(), getFoo() and isFoo().</p>
+<p>The return values supported are: primitive types (or their object wrappers), strings, enums, arrays of primitives/strings, Collection types, Map types, Classes and interfaces. When an interface is returned, it is treated equally to a configuration type, that is, it is returned as a proxy.</p>
+<p>Arrays can be represented either as comma-separated values, optionally enclosed in square brackets. For example: [ a, b, c ] and a, b,c are both considered an array of length 3 with the values "a", "b" and "c". Alternatively, you can append the array index to the key in the dictionary to obtain the same: a dictionary with "arr.0" =&gt; "a", "arr.1" =&gt; "b", "arr.2" =&gt; "c" would result in the same array as the earlier examples.</p>
+<p>Maps can be represented as single string values similarly as arrays, each value consisting of both the key and value separated by a dot. Optionally, the value can be enclosed in curly brackets. Similar to array, you can use the same dot notation using the keys. For example, a dictionary with</p>
+<p>"map" =&gt; "{key1.value1, key2.value2}"</p>
+<p>and a dictionary with</p>
+<p>"map.key1" =&gt; "value1", "map2.key2" =&gt; "value2"</p>
+<p>result in the same map being returned. Instead of a map, you could also define an interface with the methods getKey1() and getKey2 and use that interface as return type instead of a Map.</p>
+<p>In case a lookup does not yield a value from the underlying map or dictionary, the following rules are applied:</p>
+<ul>
+<li>primitive types yield their default value, as defined by the Java Specification;</li>
+<li>string, Classes and enum values yield null;</li>
+<li>for arrays, collections and maps, an empty array/collection/map is returned;</li>
+<li>for other interface types that are treated as configuration type a null-object is returned. </li>
+</ul>
+<p>Sample codes:</p>
+<p>Code example with a component that defines a Configuration Dependency using a specific callback method reference, and the method accepts in argument a configuration type (the pid is assumed to be the fqdn of the configuration type):</p>
+<div class="codehilite"><pre><span class="kd">public</span> <span class="kd">interface</span> <span class="nc">MyConfig</span> <span class="o">{</span>
+    <span class="n">String</span> <span class="nf">getAddress</span><span class="o">();</span>
+    <span class="kt">int</span> <span class="nf">getPort</span><span class="o">();</span>
+<span class="o">}</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">ServiceImpl</span> <span class="o">{</span>
+    <span class="kt">void</span> <span class="nf">modified</span><span class="o">(</span><span class="n">MyConfig</span> <span class="n">cnf</span><span class="o">)</span> <span class="o">{</span>
+        <span class="k">if</span> <span class="o">(</span><span class="n">cnf</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
+            <span class="n">String</span> <span class="n">addr</span> <span class="o">=</span> <span class="n">cnf</span><span class="o">.</span><span class="na">getAddress</span><span class="o">();</span>
+            <span class="kt">int</span> <span class="n">port</span> <span class="o">=</span> <span class="n">cnf</span><span class="o">.</span><span class="na">getPort</span><span class="o">();</span>
+            <span class="o">...</span>
+        <span class="o">}</span>
+    <span class="o">}</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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">ServiceImpl</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">withCnf</span><span class="o">(</span><span class="n">conf</span> <span class="o">-&gt;</span> <span class="n">conf</span><span class="o">.</span><span class="na">update</span><span class="o">(</span><span class="n">MyConfig</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="nl">ServiceImpl:</span><span class="o">:</span><span class="n">modified</span><span class="o">)));</span>  
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Code example with a component that defines a Configuration Dependency using a specific callback method reference which accepts a Dictionary in argument:</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span>
+           <span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">ServiceImpl</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+           <span class="o">.</span><span class="na">withCnf</span><span class="o">(</span><span class="n">conf</span> <span class="o">-&gt;</span> <span class="n">conf</span><span class="o">.</span><span class="na">pid</span><span class="o">(</span><span class="s">&quot;my.pid&quot;</span><span class="o">).</span><span class="na">update</span><span class="o">(</span><span class="nl">ServiceImpl:</span><span class="o">:</span><span class="n">modified</span><span class="o">)));</span>
+    <span class="o">}</span>
+ <span class="o">}</span>
+</pre></div>
+
+
+<p>Code example which defines a configuration dependency injected in the "ServiceImpl.updated(Dictionary)" callback:</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">ServiceImpl</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">withCnf</span><span class="o">(</span><span class="s">&quot;my.pid&quot;</span><span class="o">));</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Code example with a component that defines a Configuration Dependency using a specific callback method name:</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">ServiceImpl</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">withCnf</span><span class="o">(</span><span class="n">conf</span> <span class="o">-&gt;</span> <span class="n">conf</span><span class="o">.</span><span class="na">pid</span><span class="o">(</span><span class="s">&quot;my.pid&quot;</span><span class="o">).</span><span class="na">update</span><span class="o">(</span><span class="s">&quot;modified&quot;</span><span class="o">)));</span>  
+    <span class="o">}</span>
+ <span class="o">}</span>
+</pre></div>
+
+
 <h2 id="managing-components-outside-of-activators">Managing components outside of Activators.<a class="headerlink" href="#managing-components-outside-of-activators" title="Permanent link">&para;</a></h2>
 <p>You can manage Components outside of the Activator by using some static factory methods from the <code>DependencyManagerActivator</code> class.</p>
-<p>For example, consider a use case where you want to retrieve some informations from some already injected services, and you then want to dynamically add more dependencies from your
+<p>For example, consider a use case where you want to retrieve some information from some already injected services, and you then want to dynamically add more dependencies from your
 <code>init</code> component callback. First let's look at the Activator:</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="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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</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="o">(</span><span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">Pojo</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">withCnf</span><span class="o">(</span><span class="s">&quot;pojo.pid&quot;</span><span class="o">));</span>
     <span class="o">}</span>
 <span class="o">}</span>
@@ -378,7 +527,7 @@ what it has parsed, it will possibly add
 
     <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">Component</span> <span class="n">c</span><span class="o">)</span> <span class="o">{</span> <span class="c1">// lifecycle dm callback that allow you to add more dependencies</span>
         <span class="k">if</span> <span class="o">(</span><span class="n">xmlConfigurationRequiresEventAdmin</span><span class="o">)</span> <span class="o">{</span>
-            <span class="n">component</span><span class="o">(</span><span class="n">c</span><span class="o">,</span> <span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">withSrv</span><span class="o">(</span><span class="n">EventAdmin</span><span class="o">.</span><span class="na">class</span><span class="o">));</span>
+            <span class="n">component</span><span class="o">(</span><span class="n">c</span><span class="o">,</span> <span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">withSvc</span><span class="o">(</span><span class="n">EventAdmin</span><span class="o">.</span><span class="na">class</span><span class="o">));</span>
         <span class="o">}</span>
     <span class="o">}</span>
 <span class="o">}</span>
@@ -415,12 +564,90 @@ what it has parsed, it will possibly add
     <span class="kd">volatile</span> <span class="n">DependencyManager</span> <span class="n">m_dm</span><span class="o">;</span>
 
     <span class="kt">void</span> <span class="nf">createComponent</span><span class="o">()</span> <span class="o">{</span>
-        <span class="n">component</span><span class="o">(</span><span class="n">m_dm</span><span class="o">,</span> <span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">NewComponent</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">withSrv</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">Class</span><span class="o">,</span> <span class="n">EventAdmin</span><span class="o">.</span><span class="na">class</span><span class="o">));</span>
+        <span class="n">component</span><span class="o">(</span><span class="n">m_dm</span><span class="o">,</span> <span class="n">comp</span> <span class="o">-&gt;</span> <span class="n">comp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">NewComponent</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">withSvc</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">Class</span><span class="o">,</span> <span class="n">EventAdmin</span><span class="o">.</span><span class="na">class</span><span class="o">));</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h2 id="creating-aspect-components">Creating Aspect Components<a class="headerlink" href="#creating-aspect-components" title="Permanent link">&para;</a></h2>
+<p>Like with the original DM API, you can create aspects (service interceptors), using the "<code>aspect</code>" factory method.
+This method accepts in argument a ServiceAspectBuilder.</p>
+<p>Code example which provides a "LogService" aspect that performs spell-checking of each log message. The aspect decorates a LogService. 
+The aspect also depends on an Dictionary service that is internally used to perform log spell checking. 
+The LogService and Dictionary services are injected in the aspect implementation using reflection on class 
+fields:</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> 
+        <span class="n">aspect</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="o">(</span><span class="n">ServiceAspectBuilder</span> <span class="n">asp</span><span class="o">)</span> <span class="o">-&gt;</span> <span class="n">asp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">SpellCheckLogAspect</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">rank</span><span class="o">(</span><span class="mi">10</span><span class="o">).</span><span class="na">withSvc</span><span class="o">(</span><span class="n">Dictionary</span><span class="o">.</span><span class="na">class</span><span class="o">));</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Same more concise example which does not declare the type of the lambda builder argument:</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> 
+        <span class="n">aspect</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">asp</span> <span class="o">-&gt;</span> <span class="n">asp</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">SpellCheckLogAspect</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">rank</span><span class="o">(</span><span class="mi">10</span><span class="o">).</span><span class="na">withSvc</span><span class="o">(</span><span class="n">Dictionary</span><span class="o">.</span><span class="na">class</span><span class="o">));</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Same example, but using callbacks for injecting LogService and Dictionary services in the aspect implementation class:</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> 
+       <span class="n">aspect</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">asp</span> <span class="o">-&gt;</span> <span class="n">asp</span>
+          <span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">SpellCheckLogAspect</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">rank</span><span class="o">(</span><span class="mi">10</span><span class="o">)</span>
+          <span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="nl">SpellCheckLogAspect:</span><span class="o">:</span><span class="n">setLogService</span><span class="o">)</span>
+          <span class="o">.</span><span class="na">withSvc</span><span class="o">(</span><span class="n">Dictionary</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">svc</span> <span class="o">-&gt;</span> <span class="n">svc</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="nl">SpellCheckLogAspect:</span><span class="o">:</span><span class="n">setDictionary</span><span class="o">)));</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h2 id="creating-service-adapter-components">Creating Service Adapter Components<a class="headerlink" href="#creating-service-adapter-components" title="Permanent link">&para;</a></h2>
+<p>DM service adapters allows to create adapter services when a given type of adapted service is found in the OSGI registry.
+Using the "<code>adapter</code>" factory method, you can pass to it consumer of an <code>ServiceAdapterBuilder</code> that
+can be used to construct a DM adapter component.</p>
+<p>Code example that adapts a "Device" service to an HttpServlet service. The adapter is created using a ServiceAdapterBuilder that is passed to the lambda.</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> 
+        <span class="n">adapter</span><span class="o">(</span><span class="n">Device</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="o">(</span><span class="n">ServiceAdapterBuilder</span> <span class="n">adapt</span><span class="o">)</span> <span class="o">-&gt;</span> <span class="n">adapt</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">DeviceServlet</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">provides</span><span class="o">(</span><span class="n">HttpServlet</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">properties</span><span class="o">(</span><span class="n">alias</span> <span class="o">-&gt;</span> <span class="s">&quot;/device&quot;</span><span class="o">);</span>                    
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
 
 
+<p>Same more concise example which does not declare the type of lambda parameter:</p>
+<div class="codehilite"><pre><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="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">BundleContext</span> <span class="n">ctx</span><span class="o">,</span> <span class="n">DependencyManager</span> <span class="n">dm</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> 
+        <span class="n">adapter</span><span class="o">(</span><span class="n">Device</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">adapt</span> <span class="o">-&gt;</span> <span class="n">adapt</span><span class="o">.</span><span class="na">impl</span><span class="o">(</span><span class="n">DeviceServlet</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">provides</span><span class="o">(</span><span class="n">HttpServlet</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">properties</span><span class="o">(</span><span class="n">alias</span> <span class="o">-&gt;</span> <span class="s">&quot;/device&quot;</span><span class="o">);</span>                    
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h2 id="creating-a-bundle-adapter-component">Creating a Bundle Adapter component<a class="headerlink" href="#creating-a-bundle-adapter-component" title="Permanent link">&para;</a></h2>
+<p>A Bundle Adapter is used to create a Component when a bundle that matches a given filter is found.

[... 134 lines stripped ...]



Mime
View raw message