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

svn commit: r879268 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-dependency-manager/ documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/

Author: buildbot
Date: Fri Sep 20 23:20:12 2013
New Revision: 879268

Log:
Staging update by buildbot for felix

Added:
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html
Removed:
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-composition.html
Modified:
    websites/staging/felix/trunk/content/   (props changed)
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html
    websites/staging/felix/trunk/content/sitemap.html

Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Sep 20 23:20:12 2013
@@ -1 +1 @@
-1525172
+1525175

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html Fri Sep 20 23:20:12 2013
@@ -87,11 +87,11 @@ components can interact with the dynamic
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-component.html">Dependency Manager components annotations.</a></li>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-dependencies.html">Dependency Manager dependency annotations</a></li>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-lifecycle.html">Dependency Manager component lifecycle</a></li>
-<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-composition.html">Composition</a> Explains how a component may be implemented using multiple object instances.</li>
-<li><a href="https://bitbucket.org/marrs/bndtools-dmdemo">BndTools Tutorial</a> A BndTools based demo of DependencyManager annotations.</li>
+<li><a href="">Dependency Manager service composition.</a></li>
+<li><a href="https://bitbucket.org/marrs/bndtools-dmdemo">BndTools based demo of Dependency Manager annotations</a></li>
 </ul>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1525172 by pderop on Fri, 20 Sep 2013 23:12:27 +0000
+        Rev. 1525175 by pderop on Fri, 20 Sep 2013 23:19:31 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project

Added: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html (added)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html Fri Sep 20 23:20:12 2013
@@ -0,0 +1,150 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Felix - Dependency Manager Service Composition</title>
+    <link rel="icon" href="/res/favicon.ico">
+    <link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
+    <link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://felix.apache.org/">
+          <img border="0" alt="Apache Felix" src="/res/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="/res/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <p><a href="/news.html">news</a>  <br />
+<a href="/license.html">license</a>  <br />
+<a href="/downloads.cgi">downloads</a>  <br />
+<a href="/documentation.html">documentation</a>  <br />
+<a href="/mailinglists.html">mailing lists</a>  <br />
+<a href="/documentation/community/contributing.html">contributing</a>  <br />
+<a href="/sitemap.html">site map</a>  <br />
+<a href="http://www.apache.org/">asf</a>  <br />
+<a href="http://www.apache.org/security/">security</a>  <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">sponsorship</a>  <br />
+<a href="http://www.apache.org/foundation/thanks.html">sponsors</a>    </p>
+<iframe
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left"
+    frameborder="0"
+    scrolling="no"
+    width="135"
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Dependency Manager Annotations</a>
+      </div>
+
+      
+      <div class="tip">
+           This page is a translated version of <a href="/site/dependencymanager-annotations-composition.html" target="felix_cwiki">/site/dependencymanager-annotations-composition.html</a>. In case of
+           doubt you might want to refer to the old page.
+      </div>
+      
+      
+      <h1>Dependency Manager Service Composition</h1>
+      <p>This section shows how a component may be implemented using multiple object instances.</p>
+<p>When implementing more complex services, you often find yourself using more than one instance for a given service. 
+However, several of these instances might want to have dependencies injected. In such cases you need to tell the 
+dependency manager which instances to consider. Within a Component (or an Aspect/Adapter), you can annotate a method 
+with the @Composition annotation. This method is meant to return such composition of service instances, and the objects 
+will be considered as part of the service implementation. So, all  dependencies, as well as lifecycle annotations 
+(@Init, @Start, @Stop, @Destroy) will be applied on every objects returned by the method annotated with the @Composition annotation.</p>
+<p>The following example illustrates a composition of two object instances, which are part of the implementation of a <em>MyService</em> service:</p>
+<div class="codehilite"><pre><span class="cm">/**</span>
+<span class="cm"> * Main implementation for the MyService Service</span>
+<span class="cm"> */</span>
+<span class="nd">@Component</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyServiceImpl</span> <span class="kd">implements</span> <span class="n">MyService</span> <span class="o">{</span>
+  <span class="c1">// This object instance is also used to implement the service.</span>
+  <span class="kd">private</span> <span class="n">Helper</span> <span class="n">helper</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Helper</span><span class="o">();</span>
+
+  <span class="c1">// MyServiceImpl, and Helper objects are part of the composition</span>
+  <span class="nd">@Composition</span>
+  <span class="n">Object</span><span class="o">[]</span> <span class="nf">getComposition</span><span class="o">()</span> <span class="o">{</span>
+    <span class="k">return</span> <span class="k">new</span> <span class="n">Object</span><span class="o">[]</span> <span class="o">{</span> <span class="k">this</span><span class="o">,</span> <span class="n">helper</span> <span class="o">};</span>
+  <span class="o">}</span>
+
+  <span class="c1">// This dependency is also applied to the Helper</span>
+  <span class="nd">@ServiceDependency</span>
+  <span class="n">Dependency</span> <span class="n">dep</span><span class="o">;</span>
+
+  <span class="c1">// Same thing for this dependency</span>
+  <span class="nd">@ServiceDependency</span>
+  <span class="kt">void</span> <span class="nf">bind</span><span class="o">(</span><span class="n">Dependency2</span> <span class="n">dep2</span><span class="o">)</span> <span class="o">{}</span>
+
+  <span class="c1">// Lifecycle callbacks also applied on the Helper ...</span>
+  <span class="nd">@Init</span>
+  <span class="kt">void</span> <span class="nf">init</span><span class="o">()</span> <span class="o">{}</span>
+
+  <span class="nd">@Start</span>
+  <span class="kt">void</span> <span class="nf">start</span><span class="o">()</span> <span class="o">{}</span>
+
+  <span class="nd">@Stop</span>
+  <span class="kt">void</span> <span class="nf">stop</span><span class="o">()</span> <span class="o">{}</span>
+
+  <span class="nd">@Destroy</span><span class="o">()</span>
+  <span class="kt">void</span> <span class="nf">destroy</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">Helper</span> <span class="o">{</span>
+  <span class="c1">// Also injected, since we are part of the composition</span>
+  <span class="n">Dependency</span> <span class="n">dep</span><span class="o">;</span>
+
+  <span class="c1">// But since we are not interested by the Dependency2, we don&#39;t have to declare the bind(Dependency2) method ...</span>
+
+  <span class="c1">// We only specify the start lifecycle callback because we need to return some extra service properties which will be published</span>
+  <span class="c1">// along with the provided service ...</span>
+
+  <span class="n">Map</span> <span class="nf">start</span><span class="o">()</span> <span class="o">{</span>
+     <span class="n">Map</span> <span class="n">extraServiceProperties</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">();</span>
+     <span class="n">extraServiceProperties</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;foo&quot;</span><span class="o">,</span> <span class="s">&quot;bar&quot;</span><span class="o">);</span>
+     <span class="k">return</span> <span class="n">extraServiceProperties</span><span class="o">;</span>
+  <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Here, MyServiceImpl is the main component implementation, but is   composed of the Helper object instance. So all Dependencies defined in MyServiceImpl 
+will be also injected to the Helper (if the Helper  declares the fields or methods). The Helper may also declare lifecycle  callbacks (optionally).</p>
+      <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
+        Rev. 1525175 by pderop on Fri, 20 Sep 2013 23:19:31 +0000
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>

Modified: websites/staging/felix/trunk/content/sitemap.html
==============================================================================
--- websites/staging/felix/trunk/content/sitemap.html (original)
+++ websites/staging/felix/trunk/content/sitemap.html Fri Sep 20 23:20:12 2013
@@ -120,8 +120,8 @@
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-reference-guide.html">Apache Felix Dependency Manager - Reference Guide</a></li>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Dependency Manager Annotations</a><ul>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-how-to-build.html">Apache Felix Dependency Manager - How To Build</a></li>
-<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-composition.html">Apache Felix Dependency Manager - Using Annotations - Composition</a></li>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-component.html">Dependency Manager Components Annotations</a></li>
+<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html">Dependency Manager Service Composition</a></li>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-dependencies.html">Dependency Manager Dependencies Annotations</a></li>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-lifecycle.html">Dependency Manager Component Lifecycle</a></li>
 <li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-quickstart.html">Dependency Manager Annotations Quick Start</a></li>