felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r979376 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-dependency-manager/guides/dm-lambda.html
Date Wed, 03 Feb 2016 13:42:11 GMT
Author: buildbot
Date: Wed Feb  3 13:42:11 2016
New Revision: 979376

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 13:42:11 2016
@@ -1 +1 @@
-1728264
+1728309

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 13:42:11 2016
@@ -109,11 +109,13 @@ 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.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">DependencyActivatorBase</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="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">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>
@@ -126,9 +128,12 @@ So, in order to reduce the code size, yo
 <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>The following is the same as above, using a <code>consumer&lt;ComponentBuilder&gt;</code> lambda expression:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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="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="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">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>
@@ -136,9 +141,11 @@ So, the lambda has just to invoke the ch
 
 
 <p>And here is a more concise version where the type of the lambda parameter is not declared:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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="o">}</span>
 <span class="o">}</span>
@@ -148,9 +155,12 @@ So, the lambda has just to invoke the ch
 <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.
 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="kd">public</span> <span class="kd">class</span> <span class="nc">Activator</span> <span class="kd">extends</span> <span class="n">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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="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>
@@ -159,9 +169,11 @@ Such method accepts a <code>Consumer&lt;
 
 
 <p>The above example adds a service dependency on a LogService with a service filter. Here is a more concise version where the type of the <code>srv</code> lambda parameter is not declared:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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="o">}</span>
 <span class="o">}</span>
@@ -169,9 +181,11 @@ Such method accepts a <code>Consumer&lt;
 
 
 <p>If you depend on multiple required services (without filters), you can declare the services in one shot like this:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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="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="o">}</span>
@@ -182,9 +196,11 @@ Such method accepts a <code>Consumer&lt;
 <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>
 <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="kd">public</span> <span class="kd">class</span> <span class="nc">Activator</span> <span class="kd">extends</span> <span class="n">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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="o">}</span>
 <span class="o">}</span>
@@ -220,9 +236,11 @@ But like in the current DM API, you can
 
 
 <p>Now you can also use a more type-safe callback using a Java 8 method reference:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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="o">}</span>
 <span class="o">}</span>
@@ -230,9 +248,11 @@ But like in the current DM API, you can
 
 
 <p>or:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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="o">}</span>
 <span class="o">}</span>
@@ -243,9 +263,11 @@ But like in the current DM API, you can
 <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>
-<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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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">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="o">}</span>
@@ -254,9 +276,11 @@ In this case, you can use the "<code>cbi
 
 
 <p>or using method reference:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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">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="o">}</span>
@@ -265,9 +289,11 @@ In this case, you can use the "<code>cbi
 
 
 <p>You can chain multiple callbacks:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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">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="o">}</span>
@@ -278,9 +304,11 @@ In this case, you can use the "<code>cbi
 <h2 id="providing-a-service">Providing a service<a class="headerlink" href="#providing-a-service" title="Permanent link">&para;</a></h2>
 <p>When a component provides a service with some properties, so far it was necessary to create a Dictionary and pass it to the <code>Component.setInterface()</code> method.</p>
 <p>Now you can pass properties directly to the <code>provides</code> method as varargs of properties (a suite of key-value properties):</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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">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>
@@ -289,9 +317,11 @@ In this case, you can use the "<code>cbi
 
 <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
 service properties as a suite of "<code>key -&gt; value</code>" lambdas, like this:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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">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>
@@ -300,11 +330,13 @@ service properties as a suite of "<code>
 
 <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, considere 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 informations 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="kd">public</span> <span class="kd">class</span> <span class="nc">Activator</span> <span class="kd">extends</span> <span class="n">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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">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>
@@ -314,6 +346,7 @@ service properties as a suite of "<code>
 <p>Here, we define a Configuration dependency with a "pojo.pid" configuration pid. So, now, the Pojo will then for example be able to parse an xml from the configuration, and depending on
 what it has parsed, it will possibly add more dependencies, like this:</p>
 <div class="codehilite"><pre><span class="kn">import</span> <span class="nn">static</span> <span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">felix</span><span class="o">.</span><span class="na">dm</span><span class="o">.</span><span class="na">lambda</span><span class="o">.</span><span class="na">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">Pojo</span> <span class="o">{</span>
     <span class="kt">void</span> <span class="nf">updated</span><span class="o">(</span><span class="n">Dictionary</span> <span class="n">conf</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
@@ -330,7 +363,12 @@ what it has parsed, it will possibly add
 
 
 <p>The available variety of factory methods allows you to also create some DM objects and add them manually, like:</p>
-<div class="codehilite"><pre><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Pojo</span> <span class="o">{</span>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">static</span> <span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">felix</span><span class="o">.</span><span class="na">dm</span><span class="o">.</span><span class="na">lambda</span><span class="o">.</span><span class="na">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="kn">import</span> <span class="nn">org.apache.felix.dm.ServiceDependency</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.felix.dm.DependencyManager</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">Pojo</span> <span class="o">{</span>
     <span class="kt">void</span> <span class="nf">updated</span><span class="o">(</span><span class="n">Dictionary</span> <span class="n">conf</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
         <span class="n">parseXml</span><span class="o">(</span><span class="n">conf</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">&quot;some.xml.configuration&quot;</span><span class="o">));</span>
     <span class="o">}</span>
@@ -347,7 +385,10 @@ what it has parsed, it will possibly add
 
 
 <p>And an example where you create a new DM component from the code:</p>
-<div class="codehilite"><pre><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Pojo</span> <span class="o">{</span>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">static</span> <span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">felix</span><span class="o">.</span><span class="na">dm</span><span class="o">.</span><span class="na">lambda</span><span class="o">.</span><span class="na">DependencyManagerActivator</span><span class="o">.*;</span>
+<span class="kn">import</span> <span class="nn">org.apache.felix.dm.DependencyManager</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">Pojo</span> <span class="o">{</span>
     <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>
@@ -372,9 +413,11 @@ client, the method returns to you a <cod
 <p>And once the result will be completed, you will then be called in your start() callback, and at this point, the Tracked services will then
 be injected (using DM, optional service callbacks are always invoked after the start() callback, never before).</p>
 <p>So, the Activator looks like this:</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">DependencyActivatorBase</span> <span class="o">{</span>
+<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">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="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">Pojo</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">PojoService</span><span class="o">)</span>
            <span class="o">.</span><span class="na">withCnf</span><span class="o">(</span><span class="s">&quot;foo.pid&quot;</span><span class="o">).</span><span class="na">withSrv</span><span class="o">(</span><span class="n">HttpClient</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">Tracked</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">optional</span><span class="o">().</span><span class="na">cb</span><span class="o">(</span><span class="nl">Pojo:</span><span class="o">:</span><span class="n">bindTracked</span><span class="o">));</span>
@@ -388,6 +431,7 @@ for the result of the <code>CompletableF
 in the setPage callback, then the start() callback will be called, and finally, any registered Tracked services will be
 injected in the "bindTracked" method:</p>
 <div class="codehilite"><pre><span class="kn">import</span> <span class="nn">static</span> <span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">felix</span><span class="o">.</span><span class="na">dm</span><span class="o">.</span><span class="na">lambda</span><span class="o">.</span><span class="na">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">Pojo</span> <span class="kd">implements</span> <span class="n">PojoService</span> <span class="o">{</span>
     <span class="n">HttpClient</span> <span class="n">m_httpClient</span><span class="o">;</span> <span class="c1">// injected.</span>
@@ -551,7 +595,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. 1728264 by pderop on Wed, 3 Feb 2016 07:44:32 +0000
+        Rev. 1728309 by pderop on Wed, 3 Feb 2016 13:41:34 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project




Mime
View raw message