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

svn commit: r1036185 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-dependency-manager/reference/component-adapter.html

Author: buildbot
Date: Tue Oct  9 13:31:15 2018
New Revision: 1036185

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/reference/component-adapter.html

Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Oct  9 13:31:15 2018
@@ -1 +1 @@
-1843260
+1843261

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-adapter.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-adapter.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-adapter.html Tue Oct  9 13:31:15 2018
@@ -88,9 +88,17 @@ h2:hover > .headerlink, h3:hover > .head
   visibility: hidden;
 }
 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>
-<p>Adapters, like <a href="component-aspect.html">aspects</a>, are used to "extend" existing services, and can publish different services based on the existing one. An example would be implementing a management interface.</p>
-<p>An adapter will be applied to any service that matches the specified interface and filter. For each matching service an adapter will be created based on the adapter implementation class. The adapter will be registered with the specified interface and existing properties from the original service plus any extra properties you supply here. It will also inherit all dependencies, and if you declare the original service as a member it will be injected.</p>
-<h2 id="usage-example-using-api">Usage example using API<a class="headerlink" href="#usage-example-using-api" title="Permanent link">&para;</a></h2>
+<p>Adapters, like <a href="component-aspect.html">aspects</a>, are used to "extend" existing services, and can publish 
+different services based on the existing one. An example would be implementing a management interface.</p>
+<p>An adapter will be applied to any service that matches the specified interface and filter. 
+For each matching service an adapter will be created based on the adapter implementation class. 
+The adapter will be registered with the specified interface and existing properties from the original 
+service plus any extra properties you supply here. It will also inherit all dependencies, and if you declare 
+the original service as a member it will be injected.</p>
+<p>To define an adapter component, you need to create an <a href="http://felix.staging.apache.org/apidocs/dependencymanager/r12/org/apache/felix/dm/AdapterComponent.html">AdapterComponent</a> component
+using the DependencyActivatorBase.createAdapterComponent() or the DependencyManager.createAdapterComponent() method.
+This interface extends the Component interface in order to add extra setters methods needed to define an adapter service component.</p>
+<h2 id="usage-example">Usage example<a class="headerlink" href="#usage-example" title="Permanent link">&para;</a></h2>
 <p>Here is a sample showing a HelloServlet adapter component which creates a servlet each time a HelloService is registered in the osgi service registry with the "foo=bar" service property.</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>
     <span class="o">&amp;</span><span class="n">Override</span>
@@ -116,63 +124,8 @@ h2:hover > .headerlink, h3:hover > .head
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
-
-
-<h2 id="example-using-lambda-api">Example using Lambda API<a class="headerlink" href="#example-using-lambda-api" title="Permanent link">&para;</a></h2>
-<p>Same example using the Dependency Manager Lambda API:</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">HelloService</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">HelloServlet</span><span class="o">.</span><span class="na">class</span><span class="o">).</span><span class="na">filter</span><span class="o">(</span><span class="s">&quot;(foo=bar)&quot;</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="o">}</span>
-<span class="o">}</span>
-</pre></div>
-
-
-<h2 id="example-using-annotations">Example using annotations<a class="headerlink" href="#example-using-annotations" title="Permanent link">&para;</a></h2>
-<p>Same example using Dependency Manager Annotations:</p>
-<div class="codehilite"><pre><span class="nd">@AdapterService</span><span class="o">(</span><span class="n">adapteeService</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">adapteeFilter</span> <span class="o">=</span> <span class="s">&quot;(foo=bar)&quot;</span><span class="o">)</span>
-<span class="kd">public</span> <span class="kd">class</span> <span class="nc">HelloServlet</span> <span class="kd">extends</span> <span class="n">HttpServlet</span> <span class="o">{</span>
-    <span class="kd">volatile</span> <span class="n">HelloService</span> <span class="n">adatpee</span><span class="o">;</span> <span class="c1">// injected</span>
-
-    <span class="kt">void</span> <span class="nf">doGet</span><span class="o">(</span><span class="n">HttpServletRequest</span> <span class="n">req</span><span class="o">,</span> <span class="n">HttpServletResponse</span> <span class="n">resp</span><span class="o">)</span> <span class="o">{</span>
-        <span class="o">...</span>
-        <span class="n">resp</span><span class="o">.</span><span class="na">getWriter</span><span class="o">().</span><span class="na">println</span><span class="o">(</span><span class="n">adaptee</span><span class="o">.</span><span class="na">sayHello</span><span class="o">());</span>
-    <span class="o">}</span>
-<span class="o">}</span>
-</pre></div>
-
-
-<h3 id="annotation-attributes">Annotation attributes:<a class="headerlink" href="#annotation-attributes" title="Permanent link">&para;</a></h3>
-<hr />
-<p><strong><code>adapteeService</code></strong>  <br />
-<em>Required</em>: True  <br />
-<em>Default</em>: --</p>
-<p>Sets the adaptee service interface this adapter is applying to.</p>
-<hr />
-<p><strong><code>provides</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: all directly implemented interfaces.</p>
-<p>Sets the adapter service interface(s). By default, the directly implemented 
-interface(s) is (are) used. </p>
-<hr />
-<p><strong><code>properties</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: All inherited adaptee service properties.</p>
-<p>Sets some additional properties to use with the adapter service registration. 
-By default, the adapter will inherit all adaptee service properties.</p>
-<hr />
-<p><strong><code>adapteeFilter</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>Sets the filter condition to use with the adapted service interface.</p>
-<hr />
-<p><strong><code>factoryMethod</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>Sets the static method used to create the adapter service implementation 
-instance. By default, the default constructor of the annotated class is used.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1842518 by pderop on Mon, 1 Oct 2018 16:52:52 +0000
+        Rev. 1843261 by pderop on Tue, 9 Oct 2018 13:30:59 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project