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 00:08:19 UTC
svn commit: r879250 - in /websites/staging/felix/trunk/content: ./
documentation/subprojects/apache-felix-dependency-manager/
documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/
documentation/sub...
Author: buildbot
Date: Fri Sep 20 22:08:19 2013
New Revision: 879250
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-quickstart.html
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-spellchecker.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-quick-tour.html
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-quick-tour/apache-felix-dependency-manager-using-annotations-quick-start.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/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-how-to-build.html
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-components.html
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
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-dependencies.html
websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-lifecycle.html
websites/staging/felix/trunk/content/sitemap.html
Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Sep 20 22:08:19 2013
@@ -1 +1 @@
-1525122
+1525152
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 22:08:19 2013
@@ -82,8 +82,8 @@ describe service components. We will als
components can interact with the dynamic OSGi service model.</p>
<h1 id="table-of-contents">Table of Contents</h1>
<ul>
-<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-quick-tour/apache-felix-dependency-manager-using-annotations-quick-start.html">Quick Start</a> Provides a "Hello World" example, and shows how to compile it.</li>
-<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-quick-tour.html">Spell Checker Sample</a> Helps you with the basic concepts using a full SpellChecker sample code.</li>
+<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-quickstart.html">Provides an "Hello World" example, and shows how to compile it.</a></li>
+<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-spellchecker.html">Helps you with the basic concepts using a full SpellChecker sample code.</a></li>
<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-components.html">Writing Components</a> Explains how to write DM service components using annotations.</li>
<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-dependencies.html">Using Dependencies</a> Explains how to annotate dependencies for a given component.</li>
<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-lifecycle.html">Lifecycle</a> Explains the DM component lifecycle and how components interact with the dynamic OSGI service model.</li>
@@ -91,7 +91,7 @@ components can interact with the dynamic
<li><a href="https://bitbucket.org/marrs/bndtools-dmdemo">BndTools Tutorial</a> A BndTools based demo of DependencyManager annotations.</li>
</ul>
<div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
- Rev. 1525108 by pderop on Fri, 20 Sep 2013 19:09:41 +0000
+ Rev. 1525152 by pderop on Fri, 20 Sep 2013 22:04:01 +0000
</div>
<div class="trademarkFooter">
Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project
Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-how-to-build.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-how-to-build.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-how-to-build.html Fri Sep 20 22:08:19 2013
@@ -62,7 +62,7 @@
<div class="main">
<div class="breadcrump" style="font-size: 80%;">
- <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Apache Felix Dependency Manager - Using Annotations</a>
+ <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Dependency Manager Annotations</a>
</div>
Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-components.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-components.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-components.html Fri Sep 20 22:08:19 2013
@@ -62,7 +62,7 @@
<div class="main">
<div class="breadcrump" style="font-size: 80%;">
- <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Apache Felix Dependency Manager - Using Annotations</a>
+ <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Dependency Manager Annotations</a>
</div>
Modified: 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
==============================================================================
--- 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 (original)
+++ 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 Fri Sep 20 22:08:19 2013
@@ -62,7 +62,7 @@
<div class="main">
<div class="breadcrump" style="font-size: 80%;">
- <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Apache Felix Dependency Manager - Using Annotations</a>
+ <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Dependency Manager Annotations</a>
</div>
Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-dependencies.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-dependencies.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-dependencies.html Fri Sep 20 22:08:19 2013
@@ -62,7 +62,7 @@
<div class="main">
<div class="breadcrump" style="font-size: 80%;">
- <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Apache Felix Dependency Manager - Using Annotations</a>
+ <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Dependency Manager Annotations</a>
</div>
Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-lifecycle.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-lifecycle.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-lifecycle.html Fri Sep 20 22:08:19 2013
@@ -62,7 +62,7 @@
<div class="main">
<div class="breadcrump" style="font-size: 80%;">
- <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Apache Felix Dependency Manager - Using Annotations</a>
+ <a href="/">Home</a> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html">Dependency Manager Annotations</a>
</div>
Added: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-quickstart.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-quickstart.html (added)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-quickstart.html Fri Sep 20 22:08:19 2013
@@ -0,0 +1,199 @@
+<!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 Annotations Quick Start</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> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <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-quickstart.html" target="felix_cwiki">/site/dependencymanager-annotations-quickstart.html</a>. In case of
+ doubt you might want to refer to the old page.
+ </div>
+
+
+ <h1>Dependency Manager Annotations Quick Start</h1>
+ <p>This section presents a simple "Hello World" component defined using annotations, and also explains how to build the bundle using either Bnd, Ant, or Maven.</p>
+<h2 id="hello-world-component">Hello World Component</h2>
+<div class="codehilite"><pre><span class="n">package</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">dependencymanager</span><span class="p">.</span><span class="n">samples</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">hello</span><span class="p">;</span>
+
+<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">annotation</span><span class="p">.</span><span class="n">api</span><span class="p">.</span><span class="n">Component</span><span class="p">;</span>
+<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">annotation</span><span class="p">.</span><span class="n">api</span><span class="p">.</span><span class="n">Start</span><span class="p">;</span>
+
+<span class="p">@</span><span class="n">Component</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">HelloWorld</span> <span class="p">{</span>
+ <span class="p">@</span><span class="n">Start</span>
+ <span class="n">public</span> <span class="n">void</span> <span class="n">activate</span><span class="p">()</span> <span class="p">{</span>
+ <span class="n">System</span><span class="p">.</span><span class="n">out</span><span class="p">.</span><span class="n">println</span><span class="p">(</span>"<span class="n">Hello</span> <span class="n">world</span> !"<span class="p">);</span>
+ <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<h2 id="compiling-with-bnd">Compiling with Bnd:</h2>
+<p>The annotations must be processed at compilation phase and you have to use a special Bnd plugin (declared using the "-plugin" bnd directive):</p>
+<div class="codehilite"><pre><span class="n">Bundle</span><span class="o">-</span><span class="n">Name</span><span class="p">:</span> <span class="n">Hello</span> <span class="n">World</span> <span class="n">Using</span> <span class="n">Dependency</span> <span class="n">Manager</span> <span class="n">Annotations</span>
+<span class="n">Bundle</span><span class="o">-</span><span class="n">SymbolicName</span><span class="p">:</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">dependencymanager</span><span class="p">.</span><span class="n">samples</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">hello</span>
+<span class="n">Import</span><span class="o">-</span><span class="n">Package</span><span class="p">:</span> <span class="o">*</span>
+<span class="n">Private</span><span class="o">-</span><span class="n">Package</span><span class="p">:</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">dependencymanager</span><span class="p">.</span><span class="n">samples</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">hello</span>
+<span class="o">-</span><span class="n">plugin</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">annotation</span><span class="p">.</span><span class="n">plugin</span><span class="p">.</span><span class="n">bnd</span><span class="p">.</span><span class="n">AnnotationPlugin</span><span class="p">;</span><span class="nb">log</span><span class="p">=</span><span class="n">warn</span>
+</pre></div>
+
+
+<h2 id="compiling-with-ant">Compiling with Ant:</h2>
+<p>Since Bnd provides a Ant task, you can use the bnd directives above with the following build.xml:
+(it is assumed that directives.bnd, bnd.jar, json-20070829.jar and org.apache.felix.dependencymanager.annotation.jar are in the current directory)</p>
+<div class="codehilite"><pre><span class="nt"><project</span> <span class="na">name=</span><span class="s">"TestDM"</span> <span class="na">default=</span><span class="s">"bnd"</span><span class="nt">></span>
+ <span class="nt"><property</span> <span class="na">name=</span><span class="s">"bnd"</span> <span class="na">value=</span><span class="s">"bnd.jar"</span> <span class="nt">/></span>
+ <span class="nt"><property</span> <span class="na">name=</span><span class="s">"json"</span> <span class="na">value=</span><span class="s">"json-20070829.jar"</span> <span class="nt">/></span>
+ <span class="nt"><property</span> <span class="na">name=</span><span class="s">"dmannot"</span> <span class="na">value=</span><span class="s">"org.apache.felix.dependencymanager.annotation.jar"</span> <span class="nt">/></span>
+
+ <span class="nt"><target</span> <span class="na">name=</span><span class="s">"compile"</span><span class="nt">></span>
+ <span class="nt"><delete</span> <span class="na">dir=</span><span class="s">"target/classes"</span> <span class="na">quiet=</span><span class="s">"yes"</span> <span class="nt">/></span>
+ <span class="nt"><mkdir</span> <span class="na">dir=</span><span class="s">"target/classes"</span> <span class="nt">/></span>
+ <span class="nt"><javac</span> <span class="na">srcdir=</span><span class="s">"src/main/java"</span> <span class="na">destdir=</span><span class="s">"target/classes"</span> <span class="na">classpath=</span><span class="s">"</span><span class="cp">${</span><span class="n">dmannot</span><span class="cp">}</span><span class="s">"</span> <span class="nt">/></span>
+ <span class="nt"></target></span>
+
+ <span class="nt"><target</span> <span class="na">name=</span><span class="s">"bnd"</span> <span class="na">depends=</span><span class="s">"compile"</span><span class="nt">></span>
+ <span class="nt"><taskdef</span> <span class="na">resource=</span><span class="s">"aQute/bnd/ant/taskdef.properties"</span> <span class="na">classpath=</span><span class="s">"</span><span class="cp">${</span><span class="n">dmannot</span><span class="cp">}</span><span class="s">:</span><span class="cp">${</span><span class="n">bnd</span><span class="cp">}</span><span class="s">:</span><span class="cp">${</span><span class="n">json</span><span class="cp">}</span><span class="s">"</span> <span class="nt">/></span>
+ <span class="nt"><bnd</span> <span class="na">classpath=</span><span class="s">"target/classes"</span> <span class="na">eclipse=</span><span class="s">"false"</span> <span class="na">files=</span><span class="s">"directives.bnd"</span> <span class="na">output=</span><span class="s">"org.apache.felix.dependencymanager.samples.annotation.hello.jar"</span> <span class="nt">/></span>
+ <span class="nt"></target></span>
+<span class="nt"></project></span>
+</pre></div>
+
+
+<h2 id="compiling-with-maven">Compiling with Maven:</h2>
+<p>When compiling with Maven, you have to use the Dependency Manager Maven annotation plugin:</p>
+<div class="codehilite"><pre><span class="cp"><?xml version="1.0"?></span>
+<span class="nt"><project</span> <span class="na">xmlns=</span><span class="s">"http://maven.apache.org/POM/4.0.0"</span> <span class="na">xmlns:xsi=</span><span class="s">"http://www.w3.org/2001/XMLSchema-instance"</span>
+ <span class="na">xsi:schemaLocation=</span><span class="s">"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"</span><span class="nt">></span>
+ <span class="nt"><modelVersion></span>4.0.0<span class="nt"></modelVersion></span>
+ <span class="nt"><properties></span>
+ <span class="nt"><osgi.version></span>4.2.0<span class="nt"></osgi.version></span>
+ <span class="nt"></properties></span>
+ <span class="nt"><name></span>Hello World Using Dependency Manager Annotations<span class="nt"></name></span>
+ <span class="nt"><groupId></span>org.apache.felix<span class="nt"></groupId></span>
+ <span class="nt"><artifactId></span>org.apache.felix.dependencymanager.samples.annotation.hello<span class="nt"></artifactId></span>
+ <span class="nt"><version></span>3.0.0-SNAPSHOT<span class="nt"></version></span>
+ <span class="nt"><packaging></span>bundle<span class="nt"></packaging></span>
+ <span class="nt"><dependencies></span>
+ <span class="nt"><dependency></span>
+ <span class="nt"><groupId></span>${pom.groupId}<span class="nt"></groupId></span>
+ <span class="nt"><artifactId></span>org.apache.felix.dependencymanager.annotation<span class="nt"></artifactId></span>
+ <span class="nt"><version></span>3.0.0<span class="nt"></version></span>
+ <span class="nt"></dependency></span>
+ <span class="nt"></dependencies></span>
+ <span class="nt"><build></span>
+ <span class="nt"><plugins></span>
+ <span class="nt"><plugin></span>
+ <span class="nt"><groupId></span>org.apache.maven.plugins<span class="nt"></groupId></span>
+ <span class="nt"><artifactId></span>maven-compiler-plugin<span class="nt"></artifactId></span>
+ <span class="nt"><configuration></span>
+ <span class="nt"><source></span>1.5<span class="nt"></source></span>
+ <span class="nt"><target></span>1.5<span class="nt"></target></span>
+ <span class="nt"></configuration></span>
+ <span class="nt"></plugin></span>
+ <span class="nt"><plugin></span>
+ <span class="nt"><groupId></span>org.apache.felix<span class="nt"></groupId></span>
+ <span class="nt"><artifactId></span>maven-bundle-plugin<span class="nt"></artifactId></span>
+ <span class="nt"><version></span>2.3.4<span class="nt"></version></span>
+ <span class="nt"><extensions></span>true<span class="nt"></extensions></span>
+ <span class="nt"><configuration></span>
+ <span class="nt"><instructions></span>
+ <span class="nt"><Bundle-Name></span>Hello World Using Dependency Manager Annotations<span class="nt"></Bundle-Name></span>
+ <span class="nt"><Bundle-SymbolicName></span>org.apache.felix.dependencymanager.samples.annotation.hello<span class="nt"></Bundle-SymbolicName></span>
+ <span class="nt"><Import-Package></span>*<span class="nt"></Import-Package></span>
+ <span class="nt"><Private-Package></span>org.apache.felix.dependencymanager.samples.annotation.hello<span class="nt"></Private-Package></span>
+ <span class="nt"></instructions></span>
+ <span class="nt"></configuration></span>
+ <span class="nt"></plugin></span>
+ <span class="nt"><plugin></span>
+ <span class="nt"><groupId></span>org.apache.felix<span class="nt"></groupId></span>
+ <span class="nt"><artifactId></span>org.apache.felix.dependencymanager.annotation<span class="nt"></artifactId></span>
+ <span class="nt"><version></span>3.0.0<span class="nt"></version></span>
+ <span class="nt"><executions></span>
+ <span class="nt"><execution></span>
+ <span class="nt"><goals></span>
+ <span class="nt"><goal></span>scan<span class="nt"></goal></span>
+ <span class="nt"></goals></span>
+ <span class="nt"><configuration></span>
+ <span class="nt"><log></span>info<span class="nt"></log></span>
+ <span class="nt"></configuration></span>
+ <span class="nt"></execution></span>
+ <span class="nt"></executions></span>
+ <span class="nt"></plugin></span>
+ <span class="nt"></plugins></span>
+ <span class="nt"></build></span>
+<span class="nt"></project></span>
+</pre></div>
+ <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
+ Rev. 1525152 by pderop on Fri, 20 Sep 2013 22:04:01 +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>
Added: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-spellchecker.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-spellchecker.html (added)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-spellchecker.html Fri Sep 20 22:08:19 2013
@@ -0,0 +1,405 @@
+<!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 SpellChecker Sample</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> » <a href="/documentation.html">Documentation</a> » <a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a> » <a href="/documentation/subprojects/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> » <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-spellchecker.html" target="felix_cwiki">/site/dependencymanager-annotations-spellchecker.html</a>. In case of
+ doubt you might want to refer to the old page.
+ </div>
+
+
+ <h1>Dependency Manager SpellChecker Sample</h1>
+ <p>This section presents a quick overview of the capabilities and usage of the
+DependencyManager java 5 annotations. In particular, we will recap the DependencyManager
+annotation architecture, and identify some simple usage scenarios using a SpellChecker
+sample application with annotated components.
+The application is available from the felix trunk, in the dependencymanager/samples.annotation
+subproject.</p>
+<h2 id="architecture">Architecture</h2>
+<p>Instead of writing Activators which extends the DependencyActivatorBase class, service
+components can now be annotated using the annotations provided by the
+<em>org.apache.felix.dependencymanager.annotation</em> bundle. Annotations are not reflectively
+parsed at runtime; but we use a BND plugin which scans annotations at compilation phase
+and generates a compact metadata file in the bundle's META-INF/dependencymanager
+subdirectory. This has the following benefits:</p>
+<ul>
+<li>JVM startup speed is not affected, and class files are not parsed when the framework is starting</li>
+<li>Moreover, since the annotations are not retained by the VM at runtime, it is not necessary to load the annotation API bundle at runtime.</li>
+</ul>
+<p>At runtime, the metadata generated during the compilation phase are processed by a
+specific DependencyManager Runtime bundle, which is in charge of managing the service
+component lifecycle and dependencies. This Runtime bundle actually uses the
+DependencyManager programmatic API in order to manage the annotated components.
+Annotated components can then be inspected with the DependencyManager Gogo shell, as it is
+the case with DM components declared through the programmatic DM API.</p>
+<h2 id="registering-a-service">Registering a Service</h2>
+<p>To register a service, your can annotate your class with a <em>@Component</em> annotation, and
+an instance of your class will be registered under all directly implemented interfaces
+into the OSGi registry. You can however take control on the interfaces to be exposed, and
+in this case, you can use the <em>provides</em> attribute, which takes a list of classes to
+expose from the registry.</p>
+<p>To illustrate this, we are now introducing a SpellChecker application which provides a
+Felix "spellcheck" Gogo shell command. Gogo is the new shell supported by the Felix
+Framework. Our "spellcheck" command is implemented by the SpellChecker component which
+accepts a string as parameter. This string is then checked for proper existence. To do
+the checking, The SpellChecker class has a required/multiple (1..N) dependency over
+every available DictionaryService services. Such DictionaryService represents a real
+dictionary for a given language (it has a <em>lang</em> service property), and is
+configurable/instantiable from the OSGi Configuration Admin Service.</p>
+<p>Configuration Admin service provides a mechanism for configuring components
+(using ManagedService interfaces), and WebConsole actually implements this service.
+ConfigAdmin is also able to instantiate some Services (using ManagedServiceFactory
+interfaces).</p>
+<p>Now we have introduced the background, here is the SpellCheck component:</p>
+<div class="codehilite"><pre><span class="nd">@Component</span><span class="o">(</span><span class="n">provides</span><span class="o">={</span><span class="n">SpellChecker</span><span class="o">.</span><span class="na">class</span><span class="o">},</span>
+ <span class="n">properties</span><span class="o">={</span><span class="nd">@Property</span><span class="o">(</span><span class="n">name</span><span class="o">=</span><span class="n">CommandProcessor</span><span class="o">.</span><span class="na">COMMAND_SCOPE</span><span class="o">,</span> <span class="n">value</span><span class="o">=</span><span class="s">"dmsample.annotation"</span><span class="o">),</span>
+ <span class="nd">@Property</span><span class="o">(</span><span class="n">name</span><span class="o">=</span><span class="n">CommandProcessor</span><span class="o">.</span><span class="na">COMMAND_FUNCTION</span><span class="o">,</span> <span class="n">values</span><span class="o">={</span><span class="s">"spellcheck"</span><span class="o">})})</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">SpellChecker</span> <span class="o">{</span>
+ <span class="c1">// --- Gogo Shell command</span>
+
+ <span class="nd">@Descriptor</span><span class="o">(</span><span class="s">"checks if word is found from an available dictionary"</span><span class="o">)</span>
+ <span class="kd">public</span> <span class="kt">void</span> <span class="nf">spellcheck</span><span class="o">(</span><span class="nd">@Descriptor</span><span class="o">(</span><span class="s">"the word to check"</span><span class="o">)</span><span class="n">String</span> <span class="n">word</span><span class="o">)</span> <span class="o">{</span>
+ <span class="c1">// Check the proper existence of the word parameter, using injected DictionaryService instances</span>
+ <span class="c1">// ...</span>
+ <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>In the code above, you see that the SpellCheck is annotated with the <em>@Component</em>
+annotation. Gogo runtime does not required shell commands to implement a specific
+interface. Commands just have to register some Pojos in the OSGi registry, but the only
+thing required is to provide the Pojos with two service properties ( COMMAND_SCOPE, and
+COMMAND_FUNCTION) which will be used by the Gogo runtime when instropecting the Pojo
+for invoking the proper functions.</p>
+<p>So, coming back to the sample code, the SpellChecker class registers itself into the OSGi registry, using the <em>provides</em> attribute, which just refer to our SpellChecker class, and the two mandatory Gogo service properties are also specified using the <em>@Property</em> annotation. It is not shown here, but service properties can also be provided dynamically from a method that can return a Map, and annotated with the <em>@Start</em> lifecycle callback, but we will see this feature in a another section.</p>
+<h2 id="depending-on-a-service">Depending on a Service</h2>
+<p>Our SpellChecker component can expose itself as a Gogo shell command, but before being
+registered into the OSGi registry, we also need to be injected with two dependencies:
+one required dependency (at minimum) on a DictionaryService, and another optional one on
+a LogService. First, let's look at the DictionaryService, which is a simple interface:</p>
+<div class="codehilite"><pre><span class="kd">public</span> <span class="kd">interface</span> <span class="nc">DictionaryService</span> <span class="o">{</span>
+ <span class="cm">/**</span>
+<span class="cm"> * Check for the existence of a word.</span>
+<span class="cm"> * @param word the word to be checked.</span>
+<span class="cm"> * @return true if the word is in the dictionary, false otherwise.</span>
+<span class="cm"> */</span>
+ <span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">checkWord</span><span class="o">(</span><span class="n">String</span> <span class="n">word</span><span class="o">);</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>And here is our previous SpellChecker component, augmented with two new ServiceDependency
+annotations:</p>
+<div class="codehilite"><pre><span class="nd">@Component</span><span class="o">(</span><span class="n">provides</span><span class="o">={</span><span class="n">SpellChecker</span><span class="o">.</span><span class="na">class</span><span class="o">},</span>
+ <span class="n">properties</span><span class="o">={</span><span class="nd">@Property</span><span class="o">(</span><span class="n">name</span><span class="o">=</span><span class="n">CommandProcessor</span><span class="o">.</span><span class="na">COMMAND_SCOPE</span><span class="o">,</span> <span class="n">value</span><span class="o">=</span><span class="s">"dmsample.annotation"</span><span class="o">),</span>
+ <span class="nd">@Property</span><span class="o">(</span><span class="n">name</span><span class="o">=</span><span class="n">CommandProcessor</span><span class="o">.</span><span class="na">COMMAND_FUNCTION</span><span class="o">,</span> <span class="n">values</span><span class="o">={</span><span class="s">"spellcheck"</span><span class="o">})})</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">SpellChecker</span> <span class="o">{</span>
+ <span class="nd">@ServiceDependency</span><span class="o">(</span><span class="n">required</span> <span class="o">=</span> <span class="kc">false</span><span class="o">)</span>
+ <span class="kd">private</span> <span class="n">LogService</span> <span class="n">m_log</span><span class="o">;</span>
+
+ <span class="kd">private</span> <span class="n">CopyOnWriteArrayList</span><span class="o"><</span><span class="n">DictionaryService</span><span class="o">></span> <span class="n">m_dictionaries</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CopyOnWriteArrayList</span><span class="o"><</span><span class="n">DictionaryService</span><span class="o">>();</span>
+
+ <span class="nd">@ServiceDependency</span><span class="o">(</span><span class="n">removed</span> <span class="o">=</span> <span class="s">"removeDictionary"</span><span class="o">)</span>
+ <span class="kd">protected</span> <span class="kt">void</span> <span class="nf">addDictionary</span><span class="o">(</span><span class="n">DictionaryService</span> <span class="n">dictionary</span><span class="o">)</span> <span class="o">{</span>
+ <span class="n">m_dictionaries</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">dictionary</span><span class="o">);</span>
+ <span class="o">}</span>
+
+ <span class="kd">protected</span> <span class="kt">void</span> <span class="nf">removeDictionary</span><span class="o">(</span><span class="n">DictionaryService</span> <span class="n">dictionary</span><span class="o">)</span> <span class="o">{</span>
+ <span class="n">m_dictionaries</span><span class="o">.</span><span class="na">remove</span><span class="o">(</span><span class="n">dictionary</span><span class="o">);</span>
+ <span class="o">}</span>
+
+ <span class="c1">// --- Gogo Shell command</span>
+
+ <span class="nd">@Descriptor</span><span class="o">(</span><span class="s">"checks if word is found from an available dictionary"</span><span class="o">)</span>
+ <span class="kd">public</span> <span class="kt">void</span> <span class="nf">spellcheck</span><span class="o">(</span><span class="nd">@Descriptor</span><span class="o">(</span><span class="s">"the word to check"</span><span class="o">)</span><span class="n">String</span> <span class="n">word</span><span class="o">)</span> <span class="o">{</span>
+ <span class="n">m_log</span><span class="o">.</span><span class="na">log</span><span class="o">(</span><span class="n">LogService</span><span class="o">.</span><span class="na">LOG_INFO</span><span class="o">,</span> <span class="s">"Checking spelling of word \""</span> <span class="o">+</span> <span class="n">word</span>
+ <span class="o">+</span> <span class="s">"\" using the following dictionaries: "</span> <span class="o">+</span> <span class="n">m_dictionaries</span><span class="o">);</span>
+
+ <span class="k">for</span> <span class="o">(</span><span class="n">DictionaryService</span> <span class="n">dictionary</span> <span class="o">:</span> <span class="n">m_dictionaries</span><span class="o">)</span> <span class="o">{</span>
+ <span class="k">if</span> <span class="o">(</span><span class="n">dictionary</span><span class="o">.</span><span class="na">checkWord</span><span class="o">(</span><span class="n">word</span><span class="o">))</span> <span class="o">{</span>
+ <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"word "</span> <span class="o">+</span> <span class="n">word</span> <span class="o">+</span> <span class="s">" is correct"</span><span class="o">);</span>
+ <span class="k">return</span><span class="o">;</span>
+ <span class="o">}</span>
+ <span class="o">}</span>
+ <span class="n">System</span><span class="o">.</span><span class="na">err</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"word "</span> <span class="o">+</span> <span class="n">word</span> <span class="o">+</span> <span class="s">" is incorrect"</span><span class="o">);</span>
+ <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>There are many things to describe in the code above:</p>
+<p>First, we define an optional dependency on the LogService, by defining a
+<em>@ServiceDependency(required=false)</em> annotation on our m_logService field: This
+means that our component will be provided into the OSGi registry even if there
+is no available LogService, and in this case, a NullObject will be injected in
+our class field;
+This will avoid to check for nullability, when using the m_logService field.
+All optional dependencies applied on class fields are injected with a
+NullObject (when not available).
+The NullObject can be invoked and will do nothing. For a lot of cases that is
+good enough to handle optional dependencies. But when you really want to check
+if an optional service is there or not, then you have to apply the optional
+dependency on a callback method, which will be called when the optional
+service is available.</p>
+<p>Next comes the dependency on the DictionaryService. Here, we use a <em>ServiceDependency</em>
+annotation, but this time we apply it on a method (<em>add/removeDictionary</em>). There is no
+need to specify the "<em>required=true</em>" flag because it is the default value. Notice that
+this behavior is different from the API, where service dependencies are optional by default
+. We use a callback method, because we just need to register all available
+DictionaryService services in our dictionary list, which is used when checking word
+existence. This list is a copy on write list because the dependency may be injected at
+any time, possibly from another thread. So, using a copy on write list avoid us to use synchronized methods.</p>
+<h2 id="creating-a-service-from-configadmin">Creating a Service from ConfigAdmin</h2>
+<p>The <em>@Component</em> annotation is not the only one for creating services. Another one is
+the <em>@FactoryConfigurationAdapterService</em> annotation which allows to instantiate many
+instances of the same annotated service class from ConfigAdmin (and WebConsole).
+To illustrate this, let's take a look at our DictionaryImpl class which is part of the
+SpellChecker sample. This service is required by the SpellChecker component, when
+checking for proper word existence. And you can instantiate as many DictionaryService as
+you want, from ConfigAdmin ...</p>
+<div class="codehilite"><pre><span class="nd">@FactoryConfigurationAdapterService</span><span class="o">(</span><span class="n">factoryPid</span><span class="o">=</span><span class="s">"DictionaryImplFactoryPid"</span><span class="o">,</span> <span class="n">updated</span><span class="o">=</span><span class="s">"updated"</span><span class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">DictionaryImpl</span> <span class="kd">implements</span> <span class="n">DictionaryService</span> <span class="o">{</span>
+ <span class="cm">/**</span>
+<span class="cm"> * We store all configured words in a thread-safe data structure, because ConfigAdmin</span>
+<span class="cm"> * may invoke our updated method at any time.</span>
+<span class="cm"> */</span>
+ <span class="kd">private</span> <span class="n">CopyOnWriteArrayList</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">m_words</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CopyOnWriteArrayList</span><span class="o"><</span><span class="n">String</span><span class="o">>();</span>
+
+ <span class="cm">/**</span>
+<span class="cm"> * Our Dictionary language.</span>
+<span class="cm"> */</span>
+ <span class="kd">private</span> <span class="n">String</span> <span class="n">m_lang</span><span class="o">;</span>
+
+ <span class="cm">/**</span>
+<span class="cm"> * Our service will be initialized from ConfigAdmin, and we also handle updates in this method.</span>
+<span class="cm"> * @param config The configuration where we'll lookup our words list (key="words").</span>
+<span class="cm"> */</span>
+ <span class="kd">protected</span> <span class="kt">void</span> <span class="nf">updated</span><span class="o">(</span><span class="n">Dictionary</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="o">?></span> <span class="n">config</span><span class="o">)</span> <span class="o">{</span>
+ <span class="n">m_lang</span> <span class="o">=</span> <span class="o">(</span><span class="n">String</span><span class="o">)</span> <span class="n">config</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"lang"</span><span class="o">);</span>
+ <span class="n">m_words</span><span class="o">.</span><span class="na">clear</span><span class="o">();</span>
+ <span class="n">String</span><span class="o">[]</span> <span class="n">words</span> <span class="o">=</span> <span class="o">(</span><span class="n">String</span><span class="o">[])</span> <span class="n">config</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"words"</span><span class="o">);</span>
+ <span class="k">for</span> <span class="o">(</span><span class="n">String</span> <span class="n">word</span> <span class="o">:</span> <span class="n">words</span><span class="o">)</span> <span class="o">{</span>
+ <span class="n">m_words</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">word</span><span class="o">);</span>
+ <span class="o">}</span>
+ <span class="o">}</span>
+
+ <span class="cm">/**</span>
+<span class="cm"> * Check if a word exists if the list of words we have been configured from ConfigAdmin/WebConsole.</span>
+<span class="cm"> */</span>
+ <span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">checkWord</span><span class="o">(</span><span class="n">String</span> <span class="n">word</span><span class="o">)</span> <span class="o">{</span>
+ <span class="k">return</span> <span class="n">m_words</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="n">word</span><span class="o">);</span>
+ <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Our DictionaryImpl class implements a DictionaryService, and our class will be registered
+under that interface (all directly implemented interfaces are used when registering the
+service, but you can select some others using the <em>provides</em> attribute).
+The <em>@FactoryConfigurationAdapterService</em> annotation will instantiate our service for
+each configuration created from web console (and matching our "DictionaryImplFactoryPid"
+factoryPid).</p>
+<p>We also use the <em>updated</em> attribute, which specifies a callback method which will handle
+properties configured by ConfigAdmin. The updated callback will also be called when our
+properties are changing. Every properties are propagated to our service properties,
+unless the properties starting with a dot ("."). Configuration properties starting with
+a dot (".") are considered private and are not propagated.</p>
+<p>Notice that this annotation also supports optional meta type attributes, which allow to
+customize the ConfigAdmin GUI, with custom messages, like heading/property title,
+property type, property description, etc ...). So, let's revisit our DisctionaryImpl
+service, but this time with meta type support:</p>
+<div class="codehilite"><pre><span class="nd">@FactoryConfigurationAdapterService</span><span class="o">(</span><span class="n">factoryPid</span><span class="o">=</span><span class="s">"DictionaryImplFactoryPid"</span><span class="o">,</span>
+ <span class="n">propagate</span><span class="o">=</span><span class="kc">true</span><span class="o">,</span>
+ <span class="n">updated</span><span class="o">=</span><span class="s">"updated"</span><span class="o">,</span>
+ <span class="n">heading</span><span class="o">=</span><span class="s">"Dictionary Services"</span><span class="o">,</span>
+ <span class="n">description</span><span class="o">=</span><span class="s">"Declare here some Dictionary instances, allowing to instantiates some DictionaryService services for a given dictionary language"</span><span class="o">,</span>
+ <span class="n">metadata</span><span class="o">={</span>
+ <span class="nd">@PropertyMetaData</span><span class="o">(</span>
+ <span class="n">heading</span><span class="o">=</span><span class="s">"Dictionary Language"</span><span class="o">,</span>
+ <span class="n">description</span><span class="o">=</span><span class="s">"Declare here the language supported by this dictionary. "</span> <span class="o">+</span>
+ <span class="s">"This property will be propagated with the Dictionary Service properties."</span><span class="o">,</span>
+ <span class="n">defaults</span><span class="o">={</span><span class="s">"en"</span><span class="o">},</span>
+ <span class="n">id</span><span class="o">=</span><span class="s">"lang"</span><span class="o">,</span>
+ <span class="n">cardinality</span><span class="o">=</span><span class="mi">0</span><span class="o">),</span>
+ <span class="nd">@PropertyMetaData</span><span class="o">(</span>
+ <span class="n">heading</span><span class="o">=</span><span class="s">"Dictionary words"</span><span class="o">,</span>
+ <span class="n">description</span><span class="o">=</span><span class="s">"Declare here the list of words supported by this dictionary."</span><span class="o">,</span>
+ <span class="n">defaults</span><span class="o">={</span><span class="s">"hello"</span><span class="o">,</span> <span class="s">"world"</span><span class="o">},</span>
+ <span class="n">id</span><span class="o">=</span><span class="s">"words"</span><span class="o">,</span>
+ <span class="n">cardinality</span><span class="o">=</span><span class="n">Integer</span><span class="o">.</span><span class="na">MAX_VALUE</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">DictionaryImpl</span> <span class="kd">implements</span> <span class="n">DictionaryService</span> <span class="o">{</span>
+ <span class="o">...</span> <span class="n">code</span> <span class="n">same</span> <span class="n">as</span> <span class="n">before</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h2 id="providing-an-aspect">Providing an Aspect</h2>
+<p>As we have seen in the previous section, there are many annotations that can be used
+to specify a service. Another one is the <em>@AspectService</em> annotation. This annotation
+allows to <em>decorate</em> an existing service in order to add certain "capabilities" to it,
+like adding a specific caching mechanism to a storage service or implementing logging.
+Aspects can be plugged to an existing service at runtime, and can also be removed
+dynamically. This is transparent, and the clients using the existing service are not
+interrupted, they are just rebound with the aspect service.</p>
+<p>As an example, we go back to our SpellChecker application, and we are now looking at the
+DictionaryAspect class. This class uses the <em>@Aspect{</em>}Service annotation in order to add
+some custom words to an English DictionaryService (with the service property lang=en).
+The Extra words to add to the English Dictionary will be configured from ConfigAdmin.<br />
+That's why the class also uses a <em>@ConfigurationDependency</em> annotation:</p>
+<div class="codehilite"><pre><span class="nd">@AspectService</span><span class="o">(</span><span class="n">ranking</span> <span class="o">=</span> <span class="mi">10</span><span class="o">,</span> <span class="n">filter</span> <span class="o">=</span> <span class="s">"(lang=en)"</span><span class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">DictionaryAspect</span> <span class="kd">implements</span> <span class="n">DictionaryService</span> <span class="o">{</span>
+ <span class="cm">/**</span>
+<span class="cm"> * This is the service this aspect is applying to.</span>
+<span class="cm"> */</span>
+ <span class="kd">private</span> <span class="n">DictionaryService</span> <span class="n">m_originalDictionary</span><span class="o">;</span>
+
+ <span class="cm">/**</span>
+<span class="cm"> * We store all configured words in a thread-safe data structure, because ConfigAdmin may</span>
+<span class="cm"> * invoke our updated method at any time.</span>
+<span class="cm"> */</span>
+ <span class="kd">private</span> <span class="n">CopyOnWriteArrayList</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">m_words</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CopyOnWriteArrayList</span><span class="o"><</span><span class="n">String</span><span class="o">>();</span>
+
+ <span class="cm">/**</span>
+<span class="cm"> * Defines a configuration dependency for retrieving our english custom words (by default,</span>
+<span class="cm"> * our PID is our full class name).</span>
+<span class="cm"> */</span>
+ <span class="nd">@ConfigurationDependency</span>
+ <span class="kd">protected</span> <span class="kt">void</span> <span class="nf">updated</span><span class="o">(</span><span class="n">Dictionary</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="o">?></span> <span class="n">config</span><span class="o">)</span> <span class="o">{</span>
+ <span class="n">m_words</span><span class="o">.</span><span class="na">clear</span><span class="o">();</span>
+ <span class="n">String</span><span class="o">[]</span> <span class="n">words</span> <span class="o">=</span> <span class="o">(</span><span class="n">String</span><span class="o">[])</span> <span class="n">config</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"words"</span><span class="o">);</span>
+ <span class="k">for</span> <span class="o">(</span><span class="n">String</span> <span class="n">word</span> <span class="o">:</span> <span class="n">words</span><span class="o">)</span> <span class="o">{</span>
+ <span class="n">m_words</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">word</span><span class="o">);</span>
+ <span class="o">}</span>
+ <span class="o">}</span>
+
+ <span class="cm">/**</span>
+<span class="cm"> * Checks if a word is found from our custom word list. if not, delegate to the decorated</span>
+<span class="cm"> * dictionary.</span>
+<span class="cm"> */</span>
+ <span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">checkWord</span><span class="o">(</span><span class="n">String</span> <span class="n">word</span><span class="o">)</span> <span class="o">{</span>
+ <span class="k">if</span> <span class="o">(</span><span class="n">m_words</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="n">word</span><span class="o">))</span> <span class="o">{</span>
+ <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
+ <span class="o">}</span>
+ <span class="k">return</span> <span class="n">m_originalDictionary</span><span class="o">.</span><span class="na">checkWord</span><span class="o">(</span><span class="n">word</span><span class="o">);</span>
+ <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>The annotation does the following: because our class implements the DictionaryService
+contract, it will instantiate our service each time it finds another existing
+DictionaryService matching the filter attribute we provide in the annotation
+(filter="(lang=en)"). And it will inject the existing service in our
+m_originalDictionary field, by reflection. But we can also specify a field attribute in
+the annotation, if we want to explicitly inject the existing service in a given class
+field. So, any client depending on an English DictionaryService will be transparently
+rebound to our aspect Dictionary.</p>
+<p>In the Annotation, also notice the <em>ranking</em> attribute: It is the level used to organize
+the aspect chain ordering (multiple aspects may be applied on a given service).</p>
+<p>The <em>ConfigurationDependency</em> is another dependency that we have not seen before: it is
+used to configure the extra English words from ConfigAdmin. This annotation normally
+requires a pid parameter, which is a persistent identifier uniquely identifying our
+component, but by default, the pid is set to the fully qualified name of our class.</p>
+<p>Notice that like the <em>@FactoryConfigurationAdapterService</em>, the <em>@ConfigurationDependency</em>
+annotation also supports meta type attributes.</p>
+<h2 id="how-to-run-the-sample-code">How to run the sample code</h2>
+<p>Install the following bundles:</p>
+<div class="codehilite"><pre><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">configadmin</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">metatype</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">http</span><span class="p">.</span><span class="n">jetty</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">webconsole</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">dependencymanager</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">dependencymanager</span><span class="p">.</span><span class="n">shell</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">dependencymanager</span><span class="p">.</span><span class="n">runtime</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">dependencymanager</span><span class="p">.</span><span class="n">samples</span><span class="p">.</span><span class="n">annotation</span>
+</pre></div>
+
+
+<p>Start felix.</p>
+<p>Go to web console: in the Configuration panel, edit the "Dictionary Services" Configuration. By default, an English dictionary is displayed. Just click on "save", then refresh your web browser (click on refresh): you will see a new dictionary service instance. At this point, a DictionaryService service will be enabled (with the service property "lang=en"), and the SpellCheck component will be injected with it. Then you should see the "spellcheck" command, when typing "help" on the gogo shell.</p>
+<p>Just type "spellcheck hello", and the command should reply a fantastic message, like "word hello is correct".</p>
+<p>You can also click on the "Aspect Dictionary" button, in order to decorate the
+English dictionary with some custom words. By default, the "aspect" word is
+pre configured, but you can click on the "+" button in order to add more words.
+Then click on Save. At this point, the English DictionaryService will be decorated with
+the aspect service. So, now, if you type "spellcheck aspect", then the message
+"word aspect is correct" should be displayed.</p>
+ <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
+ Rev. 1525152 by pderop on Fri, 20 Sep 2013 22:04:01 +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 22:08:19 2013
@@ -118,16 +118,14 @@
<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-migrating-from-earlier-versions.html">Apache Felix Dependency Manager - Migrating from Earlier Versions</a></li>
<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-osgi-design-patterns.html">Apache Felix Dependency Manager - OSGi Design Patterns</a></li>
<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">Apache Felix Dependency Manager - Using Annotations</a><ul>
+<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-components.html">Apache Felix Dependency Manager - Using Annotations - Components</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/apache-felix-dependency-manager-using-annotations-dependencies.html">Apache Felix Dependency Manager - Using Annotations - Dependencies</a></li>
<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-lifecycle.html">Apache Felix Dependency Manager - Using Annotations - Lifecycle</a></li>
-<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-quick-tour.html">Apache Felix Dependency Manager - Using Annotations - Quick Tour</a><ul>
-<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-quick-tour/apache-felix-dependency-manager-using-annotations-quick-start.html">Apache Felix Dependency Manager - Using Annotations - Quick Start</a></li>
-</ul>
-</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>
+<li><a href="/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-spellchecker.html">Dependency Manager SpellChecker Sample</a></li>
</ul>
</li>
<li><a href="/documentation/subprojects/apache-felix-dependency-manager/dependency-manager-background.html">Dependency Manager Background</a></li>
@@ -193,6 +191,7 @@
<li><a href="/documentation/subprojects/apache-felix-maven-scr-plugin.html">Apache Felix Maven SCR Plugin</a><ul>
<li><a href="/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-maven-scr-plugin-use.html">Apache Felix Maven SCR Plugin Use</a></li>
<li><a href="/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-ant-task-use.html">Apache Felix SCR Ant Task Use</a></li>
+<li><a href="/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-bndtools-use.html">Apache Felix SCR Annotations BndTools Use</a></li>
<li><a href="/documentation/subprojects/apache-felix-maven-scr-plugin/extending-scr-annotations.html">Extending SCR Annotations</a></li>
<li><a href="/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html">SCR Annotations</a></li>
<li><a href="/documentation/subprojects/apache-felix-maven-scr-plugin/scr-javadoc-tags.html">SCR JavaDoc Tags</a></li>