felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r878303 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-bndtools-use.html
Date Fri, 13 Sep 2013 16:00:52 GMT
Author: buildbot
Date: Fri Sep 13 16:00:51 2013
New Revision: 878303

Staging update by buildbot for felix

    websites/staging/felix/trunk/content/   (props changed)

Propchange: websites/staging/felix/trunk/content/
--- cms:source-revision (original)
+++ cms:source-revision Fri Sep 13 16:00:51 2013
@@ -1 +1 @@

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-bndtools-use.html
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-bndtools-use.html
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-bndtools-use.html
Fri Sep 13 16:00:51 2013
@@ -68,9 +68,95 @@
       <h1>Apache Felix SCR Annotations BndTools Use</h1>
-      <p>Page under construction.</p>
+      <p>The org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin is a bnd plugin
allowing to generate SCR annotations and metatype descriptors in the Eclipse BndTools environment.
+This page describes how to install the plugin in BndTools and also provides a simple tutorial,
which won't be very fascinating, but will makes it easy
+to demonstrate the use of Apache SCR annotations within BndTools.</p>
+<p>If you are not yet familiar with BndTools or if you don't have already installed
it, you can take a look at <a href="http://bndtools.org/">BndTools homepage</a>.</p>
+<p>This tutorial has been made with Eclipse Kepler and with the latest BndTools development
+It is assumed that the eclipse workspace is currently set to ~/workspace/BNDTOOLS</p>
+<h2 id="installing-scr-bnd-plugin-in-bndtools">Installing SCR Bnd plugin in BndTools</h2>
+<p><strong>Create the cnf project</strong>:</p>
+<p>If the BndTools "cnf" project does not already exist in your workspace, then create
+<li>In the Eclipse Windows menu, click on Preference -&gt; BndTools OSGi</li>
+<li>Click on "Configuration Project/Check Now". This will create the "cnf" bndtools
+<p><strong>Compile the SCR annotations bnd plugin and copy it in cnf project</strong>:</p>
+<p>Now you have to copy the SCR annotations bnd plugin into the cnf project of your
current workspace ("BNDTOOLS" in this example). 
+For now, the plugin is not yet released, but you can build it yourself like this:</p>
+<div class="codehilite"><pre><span class="nv">$ </span>svn checkout
http://svn.apache.org/repos/asf/felix/trunk/scrplugin scrplugin
+<span class="nv">$ </span><span class="nb">cd </span>scrplugin
+<span class="nv">$ </span>mvn clean install
+<span class="nv">$ </span>mkdir ~/workspace/BNDTOOLS/cnf/plugins/org.apache.felix.scr.bnd/
+<span class="nv">$ </span>cp scrplugin/bnd-scr-plugin/target/org.apache.felix.scr.bnd-X.Y.Z-SNAPSHOT.jar
+<p><strong>Configure the default BndTools plugin path</strong>:</p>
+<p>In order to let BndTools load the SCR annotations bnd plugin, you can configure
the default BndTools plugin path:</p>
+<li>In BndTools menu, click on "BndTools Open ext/pluginpaths.bnd", then click on "Source"</li>
+<p>And append the SCR bnd plugin (${plugin-dir}/org.apache.felix.scr.bnd/org.apache.felix.scr.bnd-X.Y.Z-SNAPSHOT.jar)
to the current plugin path. 
+For example:</p>
+<p>-pluginpath: ${plugin-dir}/biz.aQute.repository/biz.aQute.repository-2.1.0.jar,
+             ${plugin-dir}/org.apache.felix.scr.bnd/org.apache.felix.scr.bnd-1.0.0-SNAPSHOT.jar</p>
+<p>You have installed the SCR annotations bnd plugin in Eclipse BndTools, and you can
now start using it (see the following Tutorial).</p>
+<h2 id="tutorial">Tutorial</h2>
+<p>In this tutorial, we'll create a "greeting" project, which provides a simple Greeting
service with a "sayHello" method, and the
+implementation will use the Apache Felix SCR annotations:</p>
+<li>From the File menu, select New -&gt; Bndtools OSGi Project for creating an
empty project, and call it "greeting".</li>
+<p>Click on bnd.bnd file of the greeting project, then click on Source, and add the
following (and then save the file)</p>
+<p>-buildpath: ${plugin-dir}/org.apache.felix.scr.bnd/org.apache.felix.scr.bnd-1.0.0-SNAPSHOT.jar;version=file
+-plugin: org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin
+Private-Package: greeting.impl
+Export-Package: greeting.api</p>
+<p>Create the greeting.api.Greeting interface:</p>
+package greeting.api;</p>
+<p>public interface Greeting {
+    void sayHello(String name);
+<p>Create the greeting.impl.GreetingImpl class:</p>
+<p>:::java  <br />
+package greeting.impl;</p>
+<p>import greeting.api.Greeting;</p>
+<p>import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;</p>
+public class GreetingImpl implements Greeting {
+    @Activate
+    private void start() {
+        System.out.println("Starting Greeting Service");
+    }</p>
+<div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
+<span class="n">public</span> <span class="n">void</span> <span
class="n">sayHello</span><span class="p">(</span><span class="n">String</span>
<span class="n">name</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>&quot;<span class="n">Hello</span> &quot; <span
class="o">+</span> <span class="n">name</span><span class="p">);</span>
+<span class="p">}</span>
+<p>Now, click on bnd.bnd and rebuild the project. you have created your first bndtools
project using SCR annotations. </p>
+<li>Create a Run descriptor (call it "run") with Apache Felix 4 With Gogo Shell.</li>
+<li>In Run requirement, add the greeting project, as well as Apache Felix SCR from
Bnd HUB.</li>
+<li>Then Run the project: you should see in the console the "Starting Greeting Service"
message displayed from the start() method.</li>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1522727 by pderop on Thu, 12 Sep 2013 21:04:55 +0000
+        Rev. 1522989 by pderop on Fri, 13 Sep 2013 16:00:34 +0000
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project

View raw message