felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r865657 [18/27] - in /websites/staging/felix/trunk/content: ./ documentation/ documentation/community/ documentation/development/ documentation/faqs/ documentation/subprojects/ documentation/subprojects/apache-felix-commons/ documentation/s...
Date Fri, 14 Jun 2013 14:11:48 GMT
Modified: websites/staging/felix/trunk/content/documentation/tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-1.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-1.html (original)
+++ websites/staging/felix/trunk/content/documentation/tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-1.html Fri Jun 14 14:11:44 2013
@@ -49,8 +49,7 @@
 <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>  <br />
-</p>
+<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"
@@ -77,75 +76,75 @@
       <h1 id="apache-felix-tutorial-example-1-service-event-listener-bundle">Apache Felix Tutorial Example 1 - Service Event Listener Bundle</h1>
 <p>This example creates a simple bundle that listens for OSGi service events. This example does not do much at first, because it only prints out the details of registering and unregistering services. In the next example we will create a bundle that implements a service, which will cause this bundle to actually do something. For now, we will just use this example to help us understand the basics of creating a bundle.</p>
 <p>A bundle gains access to the OSGi framework using a unique instance of <code>BundleContext</code>. In order for a bundle to get its unique bundle context, it must implement the <code>BundleActivator</code> interface; this interface has two methods, <code>start()</code> and <code>stop()</code>, that both receive the bundle's context and are called when the bundle is started and stopped, respectively. In the following source code, our bundle implements the <code>BundleActivator</code> interface and uses the context to add itself as a listener for service events (the file for our bundle is called <code>Activator.java</code>):</p>
-<div class="codehilite"><pre><span class="o">/*</span>
- <span class="o">*</span> <span class="n">Apache</span> <span class="n">Felix</span> <span class="n">OSGi</span> <span class="n">tutorial</span><span class="o">.</span>
-<span class="o">**/</span>
-
-<span class="nb">package</span> <span class="n">tutorial</span><span class="o">.</span><span class="n">example1</span><span class="p">;</span>
-
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">BundleActivator</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">BundleContext</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">ServiceListener</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">ServiceEvent</span><span class="p">;</span>
-
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">This</span> <span class="n">class</span> <span class="n">implements</span> <span class="n">a</span> <span class="n">simple</span> <span class="n">bundle</span> <span class="n">that</span> <span class="n">utilizes</span> <span class="n">the</span> <span class="n">OSGi</span>
- <span class="o">*</span> <span class="n">framework</span><span class="s">&#39;s event mechanism to listen for service events. Upon</span>
-<span class="s"> * receiving a service event, it prints out the event&#39;</span><span class="n">s</span> <span class="n">details</span><span class="o">.</span>
-<span class="o">**/</span>
-<span class="n">public</span> <span class="n">class</span> <span class="n">Activator</span> <span class="n">implements</span> <span class="n">BundleActivator</span><span class="p">,</span> <span class="n">ServiceListener</span>
+<div class="codehilite"><pre><span class="cm">/*</span>
+<span class="cm"> * Apache Felix OSGi tutorial.</span>
+<span class="cm">**/</span>
+
+<span class="kn">package</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">example1</span><span class="p">;</span>
+
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">BundleActivator</span><span class="p">;</span>
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">BundleContext</span><span class="p">;</span>
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">ServiceListener</span><span class="p">;</span>
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">ServiceEvent</span><span class="p">;</span>
+
+<span class="cm">/**</span>
+<span class="cm"> * This class implements a simple bundle that utilizes the OSGi</span>
+<span class="cm"> * framework&#39;s event mechanism to listen for service events. Upon</span>
+<span class="cm"> * receiving a service event, it prints out the event&#39;s details.</span>
+<span class="cm">**/</span>
+<span class="n">public</span> <span class="k">class</span> <span class="n">Activator</span> <span class="n">implements</span> <span class="n">BundleActivator</span><span class="p">,</span> <span class="n">ServiceListener</span>
 <span class="p">{</span>
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Implements</span> <span class="n">BundleActivator</span><span class="o">.</span><span class="n">start</span><span class="p">()</span><span class="o">.</span> <span class="n">Prints</span>
-     <span class="o">*</span> <span class="n">a</span> <span class="n">message</span> <span class="ow">and</span> <span class="n">adds</span> <span class="n">itself</span> <span class="n">to</span> <span class="n">the</span> <span class="n">bundle</span> <span class="n">context</span> <span class="n">as</span> <span class="n">a</span> <span class="n">service</span>
-     <span class="o">*</span> <span class="n">listener</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">context</span> <span class="n">the</span> <span class="n">framework</span> <span class="n">context</span> <span class="k">for</span> <span class="n">the</span> <span class="n">bundle</span><span class="o">.</span>
-    <span class="o">**/</span>
-    <span class="n">public</span> <span class="n">void</span> <span class="n">start</span><span class="p">(</span><span class="n">BundleContext</span> <span class="n">context</span><span class="p">)</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Implements BundleActivator.start(). Prints</span>
+<span class="cm">     * a message and adds itself to the bundle context as a service</span>
+<span class="cm">     * listener.</span>
+<span class="cm">     * @param context the framework context for the bundle.</span>
+<span class="cm">    **/</span>
+    <span class="n">public</span> <span class="k">void</span> <span class="n">start</span><span class="p">(</span><span class="n">BundleContext</span> <span class="k">context</span><span class="p">)</span>
     <span class="p">{</span>
-        <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="s">&quot;Starting to listen for service events.&quot;</span><span class="p">);</span>
-        <span class="n">context</span><span class="o">.</span><span class="n">addServiceListener</span><span class="p">(</span><span class="n">this</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="s">&quot;Starting to listen for service events.&quot;</span><span class="p">);</span>
+        <span class="k">context</span><span class="p">.</span><span class="n">addServiceListener</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
     <span class="p">}</span>
 
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Implements</span> <span class="n">BundleActivator</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span><span class="o">.</span> <span class="n">Prints</span>
-     <span class="o">*</span> <span class="n">a</span> <span class="n">message</span> <span class="ow">and</span> <span class="n">removes</span> <span class="n">itself</span> <span class="n">from</span> <span class="n">the</span> <span class="n">bundle</span> <span class="n">context</span> <span class="n">as</span> <span class="n">a</span>
-     <span class="o">*</span> <span class="n">service</span> <span class="n">listener</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">context</span> <span class="n">the</span> <span class="n">framework</span> <span class="n">context</span> <span class="k">for</span> <span class="n">the</span> <span class="n">bundle</span><span class="o">.</span>
-    <span class="o">**/</span>
-    <span class="n">public</span> <span class="n">void</span> <span class="n">stop</span><span class="p">(</span><span class="n">BundleContext</span> <span class="n">context</span><span class="p">)</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Implements BundleActivator.stop(). Prints</span>
+<span class="cm">     * a message and removes itself from the bundle context as a</span>
+<span class="cm">     * service listener.</span>
+<span class="cm">     * @param context the framework context for the bundle.</span>
+<span class="cm">    **/</span>
+    <span class="n">public</span> <span class="k">void</span> <span class="n">stop</span><span class="p">(</span><span class="n">BundleContext</span> <span class="k">context</span><span class="p">)</span>
     <span class="p">{</span>
-        <span class="n">context</span><span class="o">.</span><span class="n">removeServiceListener</span><span class="p">(</span><span class="n">this</span><span class="p">);</span>
-        <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="s">&quot;Stopped listening for service events.&quot;</span><span class="p">);</span>
+        <span class="k">context</span><span class="p">.</span><span class="n">removeServiceListener</span><span class="p">(</span><span class="k">this</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="s">&quot;Stopped listening for service events.&quot;</span><span class="p">);</span>
 
-        <span class="sr">//</span> <span class="n">Note:</span> <span class="n">It</span> <span class="n">is</span> <span class="ow">not</span> <span class="n">required</span> <span class="n">that</span> <span class="n">we</span> <span class="n">remove</span> <span class="n">the</span> <span class="n">listener</span> <span class="n">here</span><span class="p">,</span>
-        <span class="sr">//</span> <span class="n">since</span> <span class="n">the</span> <span class="n">framework</span> <span class="n">will</span> <span class="k">do</span> <span class="n">it</span> <span class="n">automatically</span> <span class="n">anyway</span><span class="o">.</span>
+        <span class="c1">// Note: It is not required that we remove the listener here,</span>
+        <span class="c1">// since the framework will do it automatically anyway.</span>
     <span class="p">}</span>
 
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Implements</span> <span class="n">ServiceListener</span><span class="o">.</span><span class="n">serviceChanged</span><span class="p">()</span><span class="o">.</span>
-     <span class="o">*</span> <span class="n">Prints</span> <span class="n">the</span> <span class="n">details</span> <span class="n">of</span> <span class="n">any</span> <span class="n">service</span> <span class="n">event</span> <span class="n">from</span> <span class="n">the</span> <span class="n">framework</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">event</span> <span class="n">the</span> <span class="n">fired</span> <span class="n">service</span> <span class="n">event</span><span class="o">.</span>
-    <span class="o">**/</span>
-    <span class="n">public</span> <span class="n">void</span> <span class="n">serviceChanged</span><span class="p">(</span><span class="n">ServiceEvent</span> <span class="n">event</span><span class="p">)</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Implements ServiceListener.serviceChanged().</span>
+<span class="cm">     * Prints the details of any service event from the framework.</span>
+<span class="cm">     * @param event the fired service event.</span>
+<span class="cm">    **/</span>
+    <span class="n">public</span> <span class="k">void</span> <span class="n">serviceChanged</span><span class="p">(</span><span class="n">ServiceEvent</span> <span class="k">event</span><span class="p">)</span>
     <span class="p">{</span>
-        <span class="n">String</span><span class="o">[]</span> <span class="n">objectClass</span> <span class="o">=</span> <span class="p">(</span><span class="n">String</span><span class="o">[]</span><span class="p">)</span>
-            <span class="n">event</span><span class="o">.</span><span class="n">getServiceReference</span><span class="p">()</span><span class="o">.</span><span class="n">getProperty</span><span class="p">(</span><span class="s">&quot;objectClass&quot;</span><span class="p">);</span>
+        <span class="n">String</span><span class="p">[]</span> <span class="n">objectClass</span> <span class="o">=</span> <span class="p">(</span><span class="n">String</span><span class="p">[])</span>
+            <span class="k">event</span><span class="p">.</span><span class="n">getServiceReference</span><span class="p">().</span><span class="n">getProperty</span><span class="p">(</span><span class="s">&quot;objectClass&quot;</span><span class="p">);</span>
 
-        <span class="k">if</span> <span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ServiceEvent</span><span class="o">.</span><span class="n">REGISTERED</span><span class="p">)</span>
+        <span class="k">if</span> <span class="p">(</span><span class="k">event</span><span class="p">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ServiceEvent</span><span class="p">.</span><span class="no">REGISTERED</span><span class="p">)</span>
         <span class="p">{</span>
-            <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span>
-                <span class="s">&quot;Ex1: Service of type &quot;</span> <span class="o">+</span> <span class="n">objectClass</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s">&quot; registered.&quot;</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="s">&quot;Ex1: Service of type &quot;</span> <span class="o">+</span> <span class="n">objectClass</span><span class="p">[</span><span class="mh">0</span><span class="p">]</span> <span class="o">+</span> <span class="s">&quot; registered.&quot;</span><span class="p">);</span>
         <span class="p">}</span>
-        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ServiceEvent</span><span class="o">.</span><span class="n">UNREGISTERING</span><span class="p">)</span>
+        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="k">event</span><span class="p">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ServiceEvent</span><span class="p">.</span><span class="no">UNREGISTERING</span><span class="p">)</span>
         <span class="p">{</span>
-            <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span>
-                <span class="s">&quot;Ex1: Service of type &quot;</span> <span class="o">+</span> <span class="n">objectClass</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s">&quot; unregistered.&quot;</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="s">&quot;Ex1: Service of type &quot;</span> <span class="o">+</span> <span class="n">objectClass</span><span class="p">[</span><span class="mh">0</span><span class="p">]</span> <span class="o">+</span> <span class="s">&quot; unregistered.&quot;</span><span class="p">);</span>
         <span class="p">}</span>
-        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ServiceEvent</span><span class="o">.</span><span class="n">MODIFIED</span><span class="p">)</span>
+        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="k">event</span><span class="p">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ServiceEvent</span><span class="p">.</span><span class="no">MODIFIED</span><span class="p">)</span>
         <span class="p">{</span>
-            <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span>
-                <span class="s">&quot;Ex1: Service of type &quot;</span> <span class="o">+</span> <span class="n">objectClass</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s">&quot; modified.&quot;</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="s">&quot;Ex1: Service of type &quot;</span> <span class="o">+</span> <span class="n">objectClass</span><span class="p">[</span><span class="mh">0</span><span class="p">]</span> <span class="o">+</span> <span class="s">&quot; modified.&quot;</span><span class="p">);</span>
         <span class="p">}</span>
     <span class="p">}</span>
 <span class="p">}</span>
@@ -153,29 +152,29 @@
 
 
 <p>After implementing the Java source code for the bundle, we must also define a manifest file that contains meta-data needed by the OSGi framework for manipulating the bundle. The manifest is packaged into a JAR file along with the Java class file associated with our bundle; the whole JAR package is actually referred to as a bundle. We create a file called <code>manifest.mf</code> that contains the following:</p>
-<div class="codehilite"><pre><span class="n">Bundle</span><span class="o">-</span><span class="n">Name:</span> <span class="n">Service</span> <span class="n">listener</span> <span class="n">example</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Description:</span> <span class="n">A</span> <span class="n">bundle</span> <span class="n">that</span> <span class="n">displays</span> <span class="n">messages</span> <span class="n">at</span> <span class="n">startup</span> <span class="ow">and</span> <span class="n">when</span> <span class="n">service</span> <span class="n">events</span> <span class="n">occur</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Vendor:</span> <span class="n">Apache</span> <span class="n">Felix</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Version:</span> <span class="mf">1.0.0</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Activator:</span> <span class="n">tutorial</span><span class="o">.</span><span class="n">example1</span><span class="o">.</span><span class="n">Activator</span>
-<span class="n">Import</span><span class="o">-</span><span class="n">Package:</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span>
+<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">Service</span> <span class="n">listener</span> <span class="n">example</span>
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Description</span><span class="p">:</span> <span class="n">A</span> <span class="n">bundle</span> <span class="n">that</span> <span class="n">displays</span> <span class="n">messages</span> <span class="n">at</span> <span class="n">startup</span> <span class="n">and</span> <span class="n">when</span> <span class="n">service</span> <span class="k">events</span> <span class="n">occur</span>
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Vendor</span><span class="p">:</span> <span class="n">Apache</span> <span class="n">Felix</span>
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Version</span><span class="p">:</span> 1<span class="p">.</span>0<span class="p">.</span>0
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Activator</span><span class="p">:</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">example1</span><span class="p">.</span><span class="n">Activator</span>
+<span class="n">Import</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">osgi</span><span class="p">.</span><span class="n">framework</span>
 </pre></div>
 
 
 <p>Most of the above meta-data is for human consumption and does not affect the OSGi framework. Only the <code>Bundle-Activator</code> and <code>Import-Package</code> meta-data is used by the framework. The <code>Bundle-Activator</code> attribute tells the framework which class implements the <code>BundleActivator</code> interface. With this information, when the OSGi framework starts the bundle, an instance of the specified class is created and its <code>start()</code> method is invoked. The created instance will also have its <code>stop()</code> method called when the framework stops the bundle. The <code>Import-Package</code> attribute informs the framework of the bundle's dependencies on external packages; all bundles with an activator must import <code>org.osgi.framework</code> since it contains the core OSGi class definitions. Any packages dependencies will be verified and resolved by the OSGi framework. (Note: Make sure your manifest file ends in a trailing carriage r
 eturn or else the last line will be ignored.)</p>
 <p>Now we need to compile the source code. To compile we must have the <code>felix.jar</code> file (found in Felix' <code>bin</code> directory) in our class path. We compile the source file using a command like:</p>
-<div class="codehilite"><pre><span class="n">javac</span> <span class="o">-</span><span class="n">d</span> <span class="n">c:</span><span class="o">\</span><span class="n">classes</span> <span class="o">*.</span><span class="n">java</span>
+<div class="codehilite"><pre><span class="n">javac</span> <span class="o">-</span><span class="n">d</span> <span class="n">c</span><span class="p">:</span><span class="o">\</span><span class="n">classes</span> <span class="o">*</span><span class="p">.</span><span class="n">java</span>
 </pre></div>
 
 
 <p>This command compiles all source files and outputs the generated classes into a subdirectory of the <code>c:\classes</code> directory; this subdirectory is <code>tutorial\example1</code>, named after the package we specified in the source file. For the above command to work, the <code>c:\classes</code> directory must exist. After compiling, we need to create a JAR file containing the generated package directories. We will also add our manifest file that contains the bundle's meta-data to the JAR file. To create the JAR file, we issue the command:</p>
-<div class="codehilite"><pre><span class="n">jar</span> <span class="n">cfm</span> <span class="n">example1</span><span class="o">.</span><span class="n">jar</span> <span class="n">manifest</span><span class="o">.</span><span class="n">mf</span> <span class="o">-</span><span class="n">C</span> <span class="n">c:</span><span class="o">\</span><span class="n">classes</span> <span class="n">tutorial</span><span class="o">\</span><span class="n">example1</span>
+<div class="codehilite"><pre><span class="n">jar</span> <span class="n">cfm</span> <span class="n">example1</span><span class="p">.</span><span class="n">jar</span> <span class="n">manifest</span><span class="p">.</span><span class="n">mf</span> <span class="o">-</span><span class="n">C</span> <span class="n">c</span><span class="p">:</span><span class="o">\</span><span class="n">classes</span> <span class="n">tutorial</span><span class="o">\</span><span class="n">example1</span>
 </pre></div>
 
 
 <p>This command creates a JAR file using the manifest file we created and includes all of the classes in the <code>tutorial\example1</code> directory inside of the <code>c:\classes</code> directory. Once the JAR file is created, we are ready to install and start the bundle.</p>
 <p>To run Felix, we follow the instructions described in usage.html. When we start Felix, it asks for a profile name, we will put all of our bundles in a profile named <code>tutorial</code>. Now we will install and start our bundle. Assuming that we created our bundle in the directory <code>c:\tutorial</code>, we can install and start it in Felix' shell using the following command:</p>
-<div class="codehilite"><pre><span class="n">start</span> <span class="n">file:</span><span class="sr">/c:/</span><span class="n">tutorial</span><span class="o">/</span><span class="n">example1</span><span class="o">.</span><span class="n">jar</span>
+<div class="codehilite"><pre><span class="n">start</span> <span class="n">file</span><span class="p">:</span><span class="o">/</span><span class="n">c</span><span class="p">:</span><span class="o">/</span><span class="n">tutorial</span><span class="o">/</span><span class="n">example1</span><span class="p">.</span><span class="n">jar</span>
 </pre></div>
 
 

Modified: websites/staging/felix/trunk/content/documentation/tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-2.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-2.html (original)
+++ websites/staging/felix/trunk/content/documentation/tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-2.html Fri Jun 14 14:11:44 2013
@@ -49,8 +49,7 @@
 <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>  <br />
-</p>
+<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"
@@ -76,24 +75,24 @@
       <h1>Apache Felix Tutorial Example 2</h1>
       <h2 id="example-2-dictionary-service-bundle">Example 2 - Dictionary Service Bundle</h2>
 <p>This example creates a bundle that implements an OSGi service. Implementing an OSGi service is a two-step process, first we must define the interface of the service and then we must define an implementation of the service interface. In this particular example, we will create a dictionary service that we can use to check if a word exists, which indicates if the word is spelled correctly or not. First, we will start by defining a simple dictionary service interface in a file called <code>DictionaryService.java</code>:</p>
-<div class="codehilite"><pre><span class="o">/*</span>
- <span class="o">*</span> <span class="n">Apache</span> <span class="n">Felix</span> <span class="n">OSGi</span> <span class="n">tutorial</span><span class="o">.</span>
-<span class="o">**/</span>
-
-<span class="nb">package</span> <span class="n">tutorial</span><span class="o">.</span><span class="n">example2</span><span class="o">.</span><span class="n">service</span><span class="p">;</span>
-
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">A</span> <span class="n">simple</span> <span class="n">service</span> <span class="n">interface</span> <span class="n">that</span> <span class="n">defines</span> <span class="n">a</span> <span class="n">dictionary</span> <span class="n">service</span><span class="o">.</span>
- <span class="o">*</span> <span class="n">A</span> <span class="n">dictionary</span> <span class="n">service</span> <span class="n">simply</span> <span class="n">verifies</span> <span class="n">the</span> <span class="n">existence</span> <span class="n">of</span> <span class="n">a</span> <span class="n">word</span><span class="o">.</span>
-<span class="o">**/</span>
-<span class="n">public</span> <span class="n">interface</span> <span class="n">DictionaryService</span>
+<div class="codehilite"><pre><span class="cm">/*</span>
+<span class="cm"> * Apache Felix OSGi tutorial.</span>
+<span class="cm">**/</span>
+
+<span class="kn">package</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">example2</span><span class="p">.</span><span class="n">service</span><span class="p">;</span>
+
+<span class="cm">/**</span>
+<span class="cm"> * A simple service interface that defines a dictionary service.</span>
+<span class="cm"> * A dictionary service simply verifies the existence of a word.</span>
+<span class="cm">**/</span>
+<span class="n">public</span> <span class="k">interface</span> <span class="n">DictionaryService</span>
 <span class="p">{</span>
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Check</span> <span class="k">for</span> <span class="n">the</span> <span class="n">existence</span> <span class="n">of</span> <span class="n">a</span> <span class="n">word</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">word</span> <span class="n">the</span> <span class="n">word</span> <span class="n">to</span> <span class="n">be</span> <span class="n">checked</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@return</span> <span class="n">true</span> <span class="k">if</span> <span class="n">the</span> <span class="n">word</span> <span class="n">is</span> <span class="n">in</span> <span class="n">the</span> <span class="n">dictionary</span><span class="p">,</span>
-     <span class="o">*</span>         <span class="n">false</span> <span class="n">otherwise</span><span class="o">.</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,</span>
+<span class="cm">     *         false otherwise.</span>
+<span class="cm">    **/</span>
     <span class="n">public</span> <span class="n">boolean</span> <span class="n">checkWord</span><span class="p">(</span><span class="n">String</span> <span class="n">word</span><span class="p">);</span>
 <span class="p">}</span>
 </pre></div>
@@ -101,80 +100,80 @@
 
 <p>The service interface is quite simple, with only one method that needs to be implemented. Notice that we put the service interface in the package <code>tutorial.example2.service</code>, instead of just putting it in <code>tutorial.example2</code>. We did this because we need to share the interface definition with other bundles, therefore it is better to separate service interfaces that need to be shared from code that does not need to be shared. Such an approach ensures a strong separation between interface and implementation.</p>
 <p>In the following source code, the bundle uses its bundle context to register the dictionary service. We implement the dictionary service as an inner class of the bundle activator class, but we could have also put it in a separate file. The source code for our bundle is as follows in a file called <code>Activator.java</code>:</p>
-<div class="codehilite"><pre><span class="o">/*</span>
- <span class="o">*</span> <span class="n">Apache</span> <span class="n">Felix</span> <span class="n">OSGi</span> <span class="n">tutorial</span><span class="o">.</span>
-<span class="o">**/</span>
-
-<span class="nb">package</span> <span class="n">tutorial</span><span class="o">.</span><span class="n">example2</span><span class="p">;</span>
-
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">Hashtable</span><span class="p">;</span>
-
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">BundleActivator</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">BundleContext</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">ServiceListener</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">ServiceEvent</span><span class="p">;</span>
-
-<span class="nb">import</span> <span class="n">tutorial</span><span class="o">.</span><span class="n">example2</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">DictionaryService</span><span class="p">;</span>
-
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">This</span> <span class="n">class</span> <span class="n">implements</span> <span class="n">a</span> <span class="n">simple</span> <span class="n">bundle</span> <span class="n">that</span> <span class="n">uses</span> <span class="n">the</span> <span class="n">bundle</span>
- <span class="o">*</span> <span class="n">context</span> <span class="n">to</span> <span class="n">register</span> <span class="n">an</span> <span class="n">English</span> <span class="n">language</span> <span class="n">dictionary</span> <span class="n">service</span>
- <span class="o">*</span> <span class="n">with</span> <span class="n">the</span> <span class="n">OSGi</span> <span class="n">framework</span><span class="o">.</span> <span class="n">The</span> <span class="n">dictionary</span> <span class="n">service</span> <span class="n">interface</span> <span class="n">is</span>
- <span class="o">*</span> <span class="nb">defined</span> <span class="n">in</span> <span class="n">a</span> <span class="n">separate</span> <span class="n">class</span> <span class="n">file</span> <span class="ow">and</span> <span class="n">is</span> <span class="n">implemented</span> <span class="n">by</span> <span class="n">an</span>
- <span class="o">*</span> <span class="n">inner</span> <span class="n">class</span><span class="o">.</span>
-<span class="o">**/</span>
-<span class="n">public</span> <span class="n">class</span> <span class="n">Activator</span> <span class="n">implements</span> <span class="n">BundleActivator</span>
+<div class="codehilite"><pre><span class="cm">/*</span>
+<span class="cm"> * Apache Felix OSGi tutorial.</span>
+<span class="cm">**/</span>
+
+<span class="kn">package</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">example2</span><span class="p">;</span>
+
+<span class="kn">import</span> <span class="nn">java</span><span class="p">.</span><span class="n">util</span><span class="p">.</span><span class="n">Hashtable</span><span class="p">;</span>
+
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">BundleActivator</span><span class="p">;</span>
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">BundleContext</span><span class="p">;</span>
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">ServiceListener</span><span class="p">;</span>
+<span class="kn">import</span> <span class="nn">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">ServiceEvent</span><span class="p">;</span>
+
+<span class="kn">import</span> <span class="nn">tutorial</span><span class="p">.</span><span class="n">example2</span><span class="p">.</span><span class="n">service</span><span class="p">.</span><span class="n">DictionaryService</span><span class="p">;</span>
+
+<span class="cm">/**</span>
+<span class="cm"> * This class implements a simple bundle that uses the bundle</span>
+<span class="cm"> * context to register an English language dictionary service</span>
+<span class="cm"> * with the OSGi framework. The dictionary service interface is</span>
+<span class="cm"> * defined in a separate class file and is implemented by an</span>
+<span class="cm"> * inner class.</span>
+<span class="cm">**/</span>
+<span class="n">public</span> <span class="k">class</span> <span class="n">Activator</span> <span class="n">implements</span> <span class="n">BundleActivator</span>
 <span class="p">{</span>
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Implements</span> <span class="n">BundleActivator</span><span class="o">.</span><span class="n">start</span><span class="p">()</span><span class="o">.</span> <span class="n">Registers</span> <span class="n">an</span>
-     <span class="o">*</span> <span class="n">instance</span> <span class="n">of</span> <span class="n">a</span> <span class="n">dictionary</span> <span class="n">service</span> <span class="n">using</span> <span class="n">the</span> <span class="n">bundle</span> <span class="n">context</span><span class="p">;</span>
-     <span class="o">*</span> <span class="n">attaches</span> <span class="n">properties</span> <span class="n">to</span> <span class="n">the</span> <span class="n">service</span> <span class="n">that</span> <span class="n">can</span> <span class="n">be</span> <span class="n">queried</span>
-     <span class="o">*</span> <span class="n">when</span> <span class="n">performing</span> <span class="n">a</span> <span class="n">service</span> <span class="n">look</span><span class="o">-</span><span class="n">up</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">context</span> <span class="n">the</span> <span class="n">framework</span> <span class="n">context</span> <span class="k">for</span> <span class="n">the</span> <span class="n">bundle</span><span class="o">.</span>
-    <span class="o">**/</span>
-    <span class="n">public</span> <span class="n">void</span> <span class="n">start</span><span class="p">(</span><span class="n">BundleContext</span> <span class="n">context</span><span class="p">)</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Implements BundleActivator.start(). Registers an</span>
+<span class="cm">     * instance of a dictionary service using the bundle context;</span>
+<span class="cm">     * attaches properties to the service that can be queried</span>
+<span class="cm">     * when performing a service look-up.</span>
+<span class="cm">     * @param context the framework context for the bundle.</span>
+<span class="cm">    **/</span>
+    <span class="n">public</span> <span class="k">void</span> <span class="n">start</span><span class="p">(</span><span class="n">BundleContext</span> <span class="k">context</span><span class="p">)</span>
     <span class="p">{</span>
         <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">props</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span><span class="p">();</span>
-        <span class="n">props</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s">&quot;Language&quot;</span><span class="p">,</span> <span class="s">&quot;English&quot;</span><span class="p">);</span>
-        <span class="n">context</span><span class="o">.</span><span class="n">registerService</span><span class="p">(</span>
-            <span class="n">DictionaryService</span><span class="o">.</span><span class="n">class</span><span class="o">.</span><span class="n">getName</span><span class="p">(),</span> <span class="k">new</span> <span class="n">DictionaryImpl</span><span class="p">(),</span> <span class="n">props</span><span class="p">);</span>
+        <span class="n">props</span><span class="p">.</span><span class="n">put</span><span class="p">(</span><span class="s">&quot;Language&quot;</span><span class="p">,</span> <span class="s">&quot;English&quot;</span><span class="p">);</span>
+        <span class="k">context</span><span class="p">.</span><span class="n">registerService</span><span class="p">(</span>
+            <span class="n">DictionaryService</span><span class="p">.</span><span class="k">class</span><span class="p">.</span><span class="n">getName</span><span class="p">(),</span> <span class="k">new</span> <span class="n">DictionaryImpl</span><span class="p">(),</span> <span class="n">props</span><span class="p">);</span>
     <span class="p">}</span>
 
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Implements</span> <span class="n">BundleActivator</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span><span class="o">.</span> <span class="n">Does</span> <span class="n">nothing</span> <span class="n">since</span>
-     <span class="o">*</span> <span class="n">the</span> <span class="n">framework</span> <span class="n">will</span> <span class="n">automatically</span> <span class="n">unregister</span> <span class="n">any</span> <span class="n">registered</span> <span class="n">services</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">context</span> <span class="n">the</span> <span class="n">framework</span> <span class="n">context</span> <span class="k">for</span> <span class="n">the</span> <span class="n">bundle</span><span class="o">.</span>
-    <span class="o">**/</span>
-    <span class="n">public</span> <span class="n">void</span> <span class="n">stop</span><span class="p">(</span><span class="n">BundleContext</span> <span class="n">context</span><span class="p">)</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Implements BundleActivator.stop(). Does nothing since</span>
+<span class="cm">     * the framework will automatically unregister any registered services.</span>
+<span class="cm">     * @param context the framework context for the bundle.</span>
+<span class="cm">    **/</span>
+    <span class="n">public</span> <span class="k">void</span> <span class="n">stop</span><span class="p">(</span><span class="n">BundleContext</span> <span class="k">context</span><span class="p">)</span>
     <span class="p">{</span>
-        <span class="sr">//</span> <span class="n">NOTE:</span> <span class="n">The</span> <span class="n">service</span> <span class="n">is</span> <span class="n">automatically</span> <span class="n">unregistered</span><span class="o">.</span>
+        <span class="c1">// NOTE: The service is automatically unregistered.</span>
     <span class="p">}</span>
 
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">A</span> <span class="n">private</span> <span class="n">inner</span> <span class="n">class</span> <span class="n">that</span> <span class="n">implements</span> <span class="n">a</span> <span class="n">dictionary</span> <span class="n">service</span><span class="p">;</span>
-     <span class="o">*</span> <span class="n">see</span> <span class="n">DictionaryService</span> <span class="k">for</span> <span class="n">details</span> <span class="n">of</span> <span class="n">the</span> <span class="n">service</span><span class="o">.</span>
-    <span class="o">**/</span>
-    <span class="n">private</span> <span class="n">static</span> <span class="n">class</span> <span class="n">DictionaryImpl</span> <span class="n">implements</span> <span class="n">DictionaryService</span>
+    <span class="cm">/**</span>
+<span class="cm">     * A private inner class that implements a dictionary service;</span>
+<span class="cm">     * see DictionaryService for details of the service.</span>
+<span class="cm">    **/</span>
+    <span class="n">private</span> <span class="k">static</span> <span class="k">class</span> <span class="n">DictionaryImpl</span> <span class="n">implements</span> <span class="n">DictionaryService</span>
     <span class="p">{</span>
-        <span class="sr">//</span> <span class="n">The</span> <span class="n">set</span> <span class="n">of</span> <span class="n">words</span> <span class="n">contained</span> <span class="n">in</span> <span class="n">the</span> <span class="n">dictionary</span><span class="o">.</span>
-        <span class="n">String</span><span class="o">[]</span> <span class="n">m_dictionary</span> <span class="o">=</span>
+        <span class="c1">// The set of words contained in the dictionary.</span>
+        <span class="n">String</span><span class="p">[]</span> <span class="n">m_dictionary</span> <span class="o">=</span>
             <span class="p">{</span> <span class="s">&quot;welcome&quot;</span><span class="p">,</span> <span class="s">&quot;to&quot;</span><span class="p">,</span> <span class="s">&quot;the&quot;</span><span class="p">,</span> <span class="s">&quot;osgi&quot;</span><span class="p">,</span> <span class="s">&quot;tutorial&quot;</span> <span class="p">};</span>
 
-        <span class="o">/**</span>
-         <span class="o">*</span> <span class="n">Implements</span> <span class="n">DictionaryService</span><span class="o">.</span><span class="n">checkWord</span><span class="p">()</span><span class="o">.</span> <span class="n">Determines</span>
-         <span class="o">*</span> <span class="k">if</span> <span class="n">the</span> <span class="n">passed</span> <span class="n">in</span> <span class="n">word</span> <span class="n">is</span> <span class="n">contained</span> <span class="n">in</span> <span class="n">the</span> <span class="n">dictionary</span><span class="o">.</span>
-         <span class="o">*</span> <span class="nv">@param</span> <span class="n">word</span> <span class="n">the</span> <span class="n">word</span> <span class="n">to</span> <span class="n">be</span> <span class="n">checked</span><span class="o">.</span>
-         <span class="o">*</span> <span class="nv">@return</span> <span class="n">true</span> <span class="k">if</span> <span class="n">the</span> <span class="n">word</span> <span class="n">is</span> <span class="n">in</span> <span class="n">the</span> <span class="n">dictionary</span><span class="p">,</span>
-         <span class="o">*</span>         <span class="n">false</span> <span class="n">otherwise</span><span class="o">.</span>
-        <span class="o">**/</span>
+        <span class="cm">/**</span>
+<span class="cm">         * Implements DictionaryService.checkWord(). Determines</span>
+<span class="cm">         * if the passed in word is contained in the dictionary.</span>
+<span class="cm">         * @param word the word to be checked.</span>
+<span class="cm">         * @return true if the word is in the dictionary,</span>
+<span class="cm">         *         false otherwise.</span>
+<span class="cm">        **/</span>
         <span class="n">public</span> <span class="n">boolean</span> <span class="n">checkWord</span><span class="p">(</span><span class="n">String</span> <span class="n">word</span><span class="p">)</span>
         <span class="p">{</span>
-            <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">toLowerCase</span><span class="p">();</span>
+            <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="p">.</span><span class="n">toLowerCase</span><span class="p">();</span>
 
-            <span class="sr">//</span> <span class="n">This</span> <span class="n">is</span> <span class="n">very</span> <span class="n">inefficient</span>
-            <span class="k">for</span> <span class="p">(</span><span class="nb">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">m_dictionary</span><span class="o">.</span><span class="nb">length</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span>
+            <span class="c1">// This is very inefficient</span>
+            <span class="k">for</span> <span class="p">(</span><span class="k">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mh">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">m_dictionary</span><span class="p">.</span><span class="n">length</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span>
             <span class="p">{</span>
-                <span class="k">if</span> <span class="p">(</span><span class="n">m_dictionary</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">word</span><span class="p">))</span>
+                <span class="k">if</span> <span class="p">(</span><span class="n">m_dictionary</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">equals</span><span class="p">(</span><span class="n">word</span><span class="p">))</span>
                 <span class="p">{</span>
                     <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
                 <span class="p">}</span>
@@ -187,30 +186,30 @@
 
 
 <p>Note that we do not need to unregister the service in the <code>stop()</code> method, because the OSGi framework will automatically do so for us. The dictionary service that we have implemented is very simple; its dictionary is a static array of only five words, so this solution is not optimal and is only intended for educational purposes. We must create a <code>manifest.mf</code> file that contains the meta-data for our bundle; the manifest file contains the following:</p>
-<div class="codehilite"><pre><span class="n">Bundle</span><span class="o">-</span><span class="n">Name:</span> <span class="n">English</span> <span class="n">dictionary</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Description:</span> <span class="n">A</span> <span class="n">bundle</span> <span class="n">that</span> <span class="n">registers</span> <span class="n">an</span> <span class="n">English</span> <span class="n">dictionary</span> <span class="n">service</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Vendor:</span> <span class="n">Apache</span> <span class="n">Felix</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Version:</span> <span class="mf">1.0.0</span>
-<span class="n">Bundle</span><span class="o">-</span><span class="n">Activator:</span> <span class="n">tutorial</span><span class="o">.</span><span class="n">example2</span><span class="o">.</span><span class="n">Activator</span>
-<span class="n">Export</span><span class="o">-</span><span class="n">Package:</span> <span class="n">tutorial</span><span class="o">.</span><span class="n">example2</span><span class="o">.</span><span class="n">service</span>
-<span class="n">Import</span><span class="o">-</span><span class="n">Package:</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">framework</span>
+<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">English</span> <span class="n">dictionary</span>
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Description</span><span class="p">:</span> <span class="n">A</span> <span class="n">bundle</span> <span class="n">that</span> <span class="n">registers</span> <span class="n">an</span> <span class="n">English</span> <span class="n">dictionary</span> <span class="n">service</span>
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Vendor</span><span class="p">:</span> <span class="n">Apache</span> <span class="n">Felix</span>
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Version</span><span class="p">:</span> 1<span class="p">.</span>0<span class="p">.</span>0
+<span class="n">Bundle</span><span class="o">-</span><span class="n">Activator</span><span class="p">:</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">example2</span><span class="p">.</span><span class="n">Activator</span>
+<span class="n">Export</span><span class="o">-</span><span class="n">Package</span><span class="p">:</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">example2</span><span class="p">.</span><span class="n">service</span>
+<span class="n">Import</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">osgi</span><span class="p">.</span><span class="n">framework</span>
 </pre></div>
 
 
 <p>We specify which class is used to activate our bundle via the <code>Bundle-Activator</code> attribute and also specify that our bundle exports a shared package using the <code>Export-Package</code> attribute. The <code>Export-Package</code> attribute makes it possible for other bundles to import our dictionary service interface. The <code>Import-Package</code> attribute informs the framework of the bundle's dependencies on external packages; all bundles with an activator must import <code>org.osgi.framework</code> since it contains the core OSGi class definitions. Any packages dependencies will be verified and resolved by the OSGi framework. (Note: Make sure your manifest file ends in a trailing carriage return or else the last line will be ignored.)</p>
 <p>To compile our source code, we need the <code>felix.jar</code> file (found in Felix' <code>bin</code> directory) in our class path. We compile the source file using a command like:</p>
-<div class="codehilite"><pre><span class="n">javac</span> <span class="o">-</span><span class="n">d</span> <span class="n">c:</span><span class="o">\</span><span class="n">classes</span> <span class="o">*.</span><span class="n">java</span>
+<div class="codehilite"><pre><span class="n">javac</span> <span class="o">-</span><span class="n">d</span> <span class="n">c</span><span class="p">:</span><span class="o">\</span><span class="n">classes</span> <span class="o">*</span><span class="p">.</span><span class="n">java</span>
 </pre></div>
 
 
 <p>This command compiles all source files and outputs the generated classes into a subdirectory of the <code>c:\classes</code> directory; this subdirectory is <code>tutorial\example2</code>, named after the package we specified in the source file. For the above command to work, the <code>c:\classes</code> directory must exist. After compiling, we need to create a JAR file containing the generated package directories. We will also add our manifest file that contains the bundle's meta-data to the JAR file. To create the JAR file, we issue the command:</p>
-<div class="codehilite"><pre><span class="n">jar</span> <span class="n">cfm</span> <span class="n">example2</span><span class="o">.</span><span class="n">jar</span> <span class="n">manifest</span><span class="o">.</span><span class="n">mf</span> <span class="o">-</span><span class="n">C</span> <span class="n">c:</span><span class="o">\</span><span class="n">classes</span> <span class="n">tutorial</span><span class="o">\</span><span class="n">example2</span>
+<div class="codehilite"><pre><span class="n">jar</span> <span class="n">cfm</span> <span class="n">example2</span><span class="p">.</span><span class="n">jar</span> <span class="n">manifest</span><span class="p">.</span><span class="n">mf</span> <span class="o">-</span><span class="n">C</span> <span class="n">c</span><span class="p">:</span><span class="o">\</span><span class="n">classes</span> <span class="n">tutorial</span><span class="o">\</span><span class="n">example2</span>
 </pre></div>
 
 
 <p>This command creates a JAR file using the manifest file we created and includes all of the classes in the <code>tutorial\example2</code> directory inside of the c:\classes directory. Once the JAR file is created, we are ready to install and start the bundle.</p>
 <p>To run Felix, we follow the instructions described in usage.html. When we start Felix, it asks for a profile name, we will put all of our bundles in a profile named <code>tutorial</code>. After running Felix, we should make sure that the bundle from Example 1 is active. We can use the Felix <code>lb</code> shell command to get a list of all bundles, their state, and their bundle identifier number. If the Example 1 bundle is not active, we should start the bundle using the <code>start</code> command and the bundle's identifier number that is displayed by the <code>lb</code> command. Now we can install and start our dictionary service bundle. Assuming that we created our bundle in the directory c:\tutorial, we can install and start it in Felix' shell using the following command:</p>
-<div class="codehilite"><pre><span class="n">start</span> <span class="n">file:</span><span class="sr">/c:/</span><span class="n">tutorial</span><span class="o">/</span><span class="n">example2</span><span class="o">.</span><span class="n">jar</span>
+<div class="codehilite"><pre><span class="n">start</span> <span class="n">file</span><span class="p">:</span><span class="o">/</span><span class="n">c</span><span class="p">:</span><span class="o">/</span><span class="n">tutorial</span><span class="o">/</span><span class="n">example2</span><span class="p">.</span><span class="n">jar</span>
 </pre></div>
 
 



Mime
View raw message