felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r849204 [5/33] - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/ documentation/subprojects/apache-felix-ipojo/ documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-devguide/ documentation/subprojects/apach...
Date Sun, 03 Feb 2013 06:45:22 GMT
Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-advanced-tutorial.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-advanced-tutorial.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-advanced-tutorial.html Sun Feb  3 06:45:21 2013
@@ -20,9 +20,45 @@
   <head>
     <title>Apache Felix - iPOJO Advanced Tutorial</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">
+    <link rel="stylesheet" href="/site/media.data/site.css" type="text/css" media="all">
+    <link rel="stylesheet" href="/ipojo/site/superfish.css" type="text/css" media="all">
+    <link rel="stylesheet" href="/ipojo/site/style.css" type="text/css" media="all">
     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+    
+    <!--
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
+    <script class="javascript" src="http://cwiki.apache.org/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
+    -->
+    
+    <script type="text/javascript" src="/ipojo/site/jquery-1.js"></script>
+    <script type="text/javascript" src="/ipojo/site/hoverIntent.js"></script>
+    <script type="text/javascript" src="/ipojo/site/superfish.js"></script> 
+    <script type="text/javascript" src="/ipojo/site/supersubs.js"></script> 
+    
+    <script type="text/javascript"> 
+     
+        $(document).ready(function(){ 
+            $("ul.sf-menu").supersubs({ 
+                minWidth:    14,   // minimum width of sub-menus in em units 
+                maxWidth:    30,   // maximum width of sub-menus in em units 
+                extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
+                                   // due to slight rounding differences and font-family 
+            }).superfish();  // call supersubs first, then superfish, so that subs are 
+                             // not display:none when measuring. Call before initialising 
+                             // containing tabs for same reason. 
+        }); 
+     
+    </script>
+    
   </head>
   <body>
     <div class="title">
@@ -37,244 +73,334 @@
         </a>
       </div>
     </div>
+  
+    <div class="main">
+    <div class="main">
+    <div class="page-header">
+    <img src="/ipojo/site/header.png" class="header">
+    <a href="http://ipojo.org"><img src="/ipojo/site/ipojo.png" width="225" class="header-logo"></a>
+    <ul class="sf-menu sf-js-enabled sf-shadow" id="ipojo-menu">
+    <li class="current">
+    <!-- Menu Overview -->
+    <a href="#" class="sf-with-ul">Overview<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+    <ul>
+        <li>
+        <a href="">Home</a>                          
+        </li>
+        <li>
+        <a href="">Why choose iPOJO</a>
+        </li>
+        <li>
+        <a href="">Success stories</a>
+        </li>
+        <li>
+        <a href="">Features</a>
+        </li>
+    </ul>
+    </li>   
     
-    <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>  <br />
-</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>
+    <li class="">           
+    <!-- Menu download -->
+    <li>
+    <a href="/downloads.cgi">Download </a>
+    </li>
     
-    <div class="main">
-      <div class="breadcrump" style="font-size: 80%;">
-        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects.html">Apache Felix Subproject Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects/apache-felix-ipojo.html">Apache Felix iPOJO</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted.html">apache-felix-ipojo-gettingstarted</a>
-      </div>
-
+    <li class="">                   
+    <!-- Menu Documentation -->
+    <a href="#" class="sf-with-ul">Documentation<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+    <ul>
+        <!-- sub-menu : getting started -->
+        <li class="">
+        <a href="#" class="sf-with-ul">Getting Started<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+        <ul>
+         <li><a href="">iPOJO in 10 minutes</a></li>
+         <li><a href="">Using Annotations</a></li>
+         <li><a href="">Maven tutorial</a></li>
+         <li><a href="">Advanced tutorial</a></li>
+         <li><a href="">Using Distributed OSGi</a></li>
+         <li><a href="">Application Composition</a></li>
+        </ul>
+        </li> <!-- end of getting started -->
+        <!-- sub menu : Describing Components -->
+         <li class="">
+            <a href="" class="sf-with-ul">Describing components<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+            <ul>
+            <li><a href="">Requiring a service</a></li>
+            <li><a href="">Providing a service</a></li>
+            <li><a href="">Lifecycle management</a></li>
+            <li><a href="">Configuration</a></li>
+            <li><a href="">Introspection</a></li>
+            <li><a href="">Impacting the lifecycle</a></li>
+            <li><a href="">Asynchronous communication</a></li>
+            <li><a href="">JMX management</a></li>
+            <li><a href="">Extender pattern</a></li>
+            <li><a href="">Whiteboard pattern</a></li>
+            <li><a href="">Temporal dependencies</a></li>
+            </ul>
+         </li> <!-- End of describing components -->
+        <!-- sub-menu : User Guide -->
+        <li class="">
+        <a href="" class="sf-with-ul">User Guide<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+            <ul>
+            <li><a href="">iPOJO and config admin</a></li>
+            <li><a href="">Factories and Instances</a></li>
+            <li><a href="">XML Schemas</a></li>
+            <li><a href="">API</a></li>
+            <li><a href="">Testing components</a></li>
+            <li><a href="">Eclipse Integration</a></li>
+            <li><a href="">FAQ</a></li>
+            <li><a href="">Reference Card</a></li>
+            </ul>
+        </li> <!-- end of user guide -->
+        <!-- sub-menu : Dev Guide -->
+        <li> 
+        <a href="#" class="sf-with-ul">Advanced Topics<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+           <ul>
+            <li><a href="http://felix.apache.org/ipojo/api/1.6.0">Javadoc</a></li>
+            <li><a href="">Handler development</a></li>
+            <li><a href="">Manipulation Metadata </a></li>
+            <li><a href="">Dive into the iPOJO Manipulation depths</a></li>
+           </ul>
+        </li> <!-- End of Dev guide -->
+    </ul> 
+    </li> <!-- End of doc -->
+    <!-- Menu 4 : Tools -->
+    <li class="">
+    <a href="#" class="sf-with-ul">Tools<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+    <ul>
+       <li><a href="">Ant Task</a></li>
+       <li><a href="">Eclipse Plugin</a></li>
+       <li><a href="">Maven Plugin</a></li>
+       <li><a href="">`arch` shell command</a></li>
+       <li><a href="">Online Manipulator</a></li>
+       <li><a href="">Webconsole plugin</a></li>
+       <li><a href="">Junit4OSGi</a></li>
+    </ul>   
+    </li><!-- End of tools -->  
+    <!-- Menu 5 : Support -->
+    <li>
+    <a href="">Support </a>
+    </li>
+    <!-- End of the menu 5 -->          
+    <!-- Menu 6 : Misc -->
+    <li class="">
+    <a href="#" class="sf-with-ul">Misc<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
+    <ul>
+       <li><a href="">Supported JVMs</a></li>
+       <li><a href="">Supported OSGi Implementations</a></li>
+       <li><a href="http://ipojo-dark-side.blogspot.com">iPOJO's Dark Side Blog</a></li>
+       <li><a href="">Article & Presentations</a></li>
+       <li><a href="http://www.apache.org/">ASF</a></li>
+       <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
+       <li><a href="http://www.apache.org/foundation/thanks.html">Sponsors</a></li>
+    </ul>
+    </li><!-- End of misc -->
+    </ul> <!-- End of the menu -->
+    </div> <!-- Page header -->
+  
+      <!-- 
       
       <div class="tip">
            This page is a translated version of <a href="/site/ipojo-advanced-tutorial.html" target="felix_cwiki">/site/ipojo-advanced-tutorial.html</a>. In case of
            doubt you might want to refer to the old page.
       </div>
       
+      -->
       
       <h1>iPOJO Advanced Tutorial</h1>
-      <p>{include:apache-felix-ipojo-header}</p>
-<div class="content">
-
-# The iPOJO Snack Bar
-
-*This tutorial illustrates some advanced features of iPOJO*
-
-{div:class=toc}
+      
+      <div class="content">
+        <h1 id="the-ipojo-snack-bar">The iPOJO Snack Bar</h1>
+<p><em>This tutorial illustrates some advanced features of iPOJO</em></p>
+<p>{div:class=toc}
 [TOC]
-{div}
-
-## Context
-This tutorial is based on a very simple application; customers are using a vendor service to buy hot dog or pop corn according to the availability of appropriate providers. Both of the vendors implement (and provide) the vendor service. The hot dog vendor depends on two others services to get the ingredients (buns and wiener). To sell pop corn, the pop corn vendor requires having enough corn in stock.
-!vendor.png!
-## Preparing the tutorial
-The tutorial archive is available [here](http://people.apache.org/~clement/ipojo/tutorials/advanced/advanced.tutorial.zip). This archive contains both the source code and a pre-configured version of Felix. First, unzip the archive. Then, launch `ant` to compile the bundles composing this tutorial. Once compiled, you can launch Felix and start the tutorial. To launch, Felix launch the following command from the `felix` directory:
-
-    java -jar bin/felix.jar
-
-## Writing a component providing two services
-The sources of this project are inside the *vendor.buns-and-wieners* directory.
-The hot dog vendor requires at the same time the bun service and the wiener service. In our application these services are provided by the same component. This component can be implemented as follows (src\org\apache\felix\ipojo\example\vendor\provider\BunWienerProvider.java):
-
-{code:java} 
-public class BunWienerProvider implements BunService, WienerService {
-
-    public void getBun() {
-        System.out.println("Get a bun");
-    }
-
-    public void getWiener() {
-        System.out.println("Get a wiener");
-    }
-}
-
-    This class just implements the two service interfaces. Its descriptor (contained in the metadata.xml file) is:
-    {code:xml}
-    <ipojo>
-    <component 
-        classname="org.apache.felix.ipojo.example.vendor.provider.BunWienerProvider" 
-        name="buns_and_wieners" public="false">
-        <provides/>
-    </component>
-
-    <instance component="buns_and_wieners"/>
-    </ipojo>
-
-In the descriptor, we declare a component type for this vendor which contains the implementation class. The "classname" attribute contains the qualified name of the component implementation. The "name" attribute is the component type name. It is only used to refer to this type.
-
-The "public=false" attribute disables factory exposition. A component type publishing a factory provides a way to create instance of this type from outside this descriptor. In our case, we want to guarantee that only one instance (singleton) can be created, so we disable the factory mechanism.
-
-iPOJO manages service publication and providing automatically at runtime. The "<provides/>" element means that the component provides services. If this element is not present, iPOJO will publish all implemented interfaces by the implementation class (and parent class too). In our case, it will publish the BunService and WienerService interfaces.
-
-Finally, we create one instance of our component. The instance contains the component attribute describing the component type to use. We use the component type name to target the wanted component type. 
-
-At runtime, the bundle containing this component will create an instance which provides the BunService and the WienerService.
-
-## Publishing service properties
-The sources of this project are inside the *vendor.hotdog* directory.
-The hot dog vendor only provides the Vendor service. To provide this service, it uses a bun service and a wiener service. The following code (contained in the *src/org/apache/felix/ipojo/example/vendor/hotdog/HotDogVendor.java* file) shows a very simple implementation of this component:
-
-{code:java}
-public class HotDogVendor implements Vendor {
-
-    /**
-     * Bun provider (required service).
-     */
-    private Bun bunProvider;
-
-    /**
-     * Wiener provider (required service). 
-     */
-    private Wiener wienerProvider;
-
-    /**
-     * Sell method.
-     * To provide an hotdog, the vendor consume a bun and a wiener.
-     * This method is synchronized to avoid serving to client 
-     * at the same time.
-     * @return a hotdog.
-     * @see org.apache.felix.ipojo.example.vendor.service.Vendor#sell()
-     */
-    public synchronized Product sell() {
-        bunProvider.getBun();
-        wienerProvider.getWiener();
-        return new HotDog();
-    }
-
-    Once implemented, we need to describe this component type. The descriptor file is the _metadata.xml_ file. The field attributes in the "requires" elements are used to inject the required services. At runtime, iPOJO injects automatically a BunService provider in the "bunProvider" field and a WienerService provider in the "wienerProvider" field. The implementation uses these fields the same way it would have used any other fields (as illustrated in the sell method).
-    {code:xml}
-    <ipojo>
-    <component 
-       classname="org.apache.felix.ipojo.example.vendor.hotdog.HotDogVendor"
-       name="HD" public="false">
-        <provides/>
-        <requires field="bunProvider"/>
-        <requires field="wienerProvider"/>
-    </component>
-
-    <instance component="HD"/>
-    </ipojo>
-
-The component type declares a provided service (the Vendor Service). Then, the component declares the two service dependencies (using the "requires" element). However, we would like to add a service property on the Vendor service describing the sold product (here, "hotdog"). To achieve this, we just need to add a property element in the "provides" tags: 
-
-    <ipojo>
-    <component 
-       classname="org.apache.felix.ipojo.example.vendor.hotdog.HotDogVendor" 
-       name="HD" public="false">
-        <provides>
-            <property name="product" type="string" value="hotdog"/>
-        </provides>
-        <requires field="bunProvider"/>
-        <requires field="wienerProvider"/>
-    </component>
-
-    <instance component="HD"/>
-    </ipojo>
-
-iPOJO then publishes the "product" property in the "vendor" service registration. This property has the "hotdog" value.
-
-## Publishing 'dynamic' properties
-
-The bun service and the wiener service can also expose service properties. In our case, these service properties will describe the stock of ingredients. Each time the service is used, the property value is decreased.
-To achieve this, we modify the current implementation to add a field representing the property:
-
-{code:java}
-public class BunWienerProvider implements BunService, WienerService {
-
-    private int bunStock;
+{div}</p>
+<h2 id="context">Context</h2>
+<p>This tutorial is based on a very simple application; customers are using a vendor service to buy hot dog or pop corn according to the availability of appropriate providers. Both of the vendors implement (and provide) the vendor service. The hot dog vendor depends on two others services to get the ingredients (buns and wiener). To sell pop corn, the pop corn vendor requires having enough corn in stock.
+!vendor.png!</p>
+<h2 id="preparing-the-tutorial">Preparing the tutorial</h2>
+<p>The tutorial archive is available <a href="http://people.apache.org/~clement/ipojo/tutorials/advanced/advanced.tutorial.zip">here</a>. This archive contains both the source code and a pre-configured version of Felix. First, unzip the archive. Then, launch <code>ant</code> to compile the bundles composing this tutorial. Once compiled, you can launch Felix and start the tutorial. To launch, Felix launch the following command from the <code>felix</code> directory:</p>
+<div class="codehilite"><pre><span class="n">java</span> <span class="o">-</span><span class="n">jar</span> <span class="n">bin</span><span class="o">/</span><span class="n">felix</span><span class="o">.</span><span class="n">jar</span>
+</pre></div>
+
+
+<h2 id="writing-a-component-providing-two-services">Writing a component providing two services</h2>
+<p>The sources of this project are inside the <em>vendor.buns-and-wieners</em> directory.
+The hot dog vendor requires at the same time the bun service and the wiener service. In our application these services are provided by the same component. This component can be implemented as follows (src\org\apache\felix\ipojo\example\vendor\provider\BunWienerProvider.java):</p>
+<p>{code:java} 
+public class BunWienerProvider implements BunService, WienerService {</p>
+<div class="codehilite"><pre><span class="n">public</span> <span class="n">void</span> <span class="n">getBun</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;Get a bun&quot;</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">void</span> <span class="n">getWiener</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;Get a wiener&quot;</span><span class="p">);</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}</p>
+<div class="codehilite"><pre>This class just implements the two service interfaces. Its descriptor (contained in the metadata.xml file) is:
+{code:xml}
+<span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;component</span> 
+    <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.provider.BunWienerProvider&quot;</span> 
+    <span class="na">name=</span><span class="s">&quot;buns_and_wieners&quot;</span> <span class="na">public=</span><span class="s">&quot;false&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;provides/&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;buns_and_wieners&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
+
+
+<p>In the descriptor, we declare a component type for this vendor which contains the implementation class. The "classname" attribute contains the qualified name of the component implementation. The "name" attribute is the component type name. It is only used to refer to this type.</p>
+<p>The "public=false" attribute disables factory exposition. A component type publishing a factory provides a way to create instance of this type from outside this descriptor. In our case, we want to guarantee that only one instance (singleton) can be created, so we disable the factory mechanism.</p>
+<p>iPOJO manages service publication and providing automatically at runtime. The "<provides/>" element means that the component provides services. If this element is not present, iPOJO will publish all implemented interfaces by the implementation class (and parent class too). In our case, it will publish the BunService and WienerService interfaces.</p>
+<p>Finally, we create one instance of our component. The instance contains the component attribute describing the component type to use. We use the component type name to target the wanted component type. </p>
+<p>At runtime, the bundle containing this component will create an instance which provides the BunService and the WienerService.</p>
+<h2 id="publishing-service-properties">Publishing service properties</h2>
+<p>The sources of this project are inside the <em>vendor.hotdog</em> directory.
+The hot dog vendor only provides the Vendor service. To provide this service, it uses a bun service and a wiener service. The following code (contained in the <em>src/org/apache/felix/ipojo/example/vendor/hotdog/HotDogVendor.java</em> file) shows a very simple implementation of this component:</p>
+<p>{code:java}
+public class HotDogVendor implements Vendor {</p>
+<div class="codehilite"><pre><span class="o">/**</span>
+ <span class="o">*</span> <span class="n">Bun</span> <span class="n">provider</span> <span class="p">(</span><span class="n">required</span> <span class="n">service</span><span class="p">)</span><span class="o">.</span>
+ <span class="o">*/</span>
+<span class="n">private</span> <span class="n">Bun</span> <span class="n">bunProvider</span><span class="p">;</span>
+
+<span class="o">/**</span>
+ <span class="o">*</span> <span class="n">Wiener</span> <span class="n">provider</span> <span class="p">(</span><span class="n">required</span> <span class="n">service</span><span class="p">)</span><span class="o">.</span> 
+ <span class="o">*/</span>
+<span class="n">private</span> <span class="n">Wiener</span> <span class="n">wienerProvider</span><span class="p">;</span>
+
+<span class="o">/**</span>
+ <span class="o">*</span> <span class="n">Sell</span> <span class="n">method</span><span class="o">.</span>
+ <span class="o">*</span> <span class="n">To</span> <span class="n">provide</span> <span class="n">an</span> <span class="n">hotdog</span><span class="p">,</span> <span class="n">the</span> <span class="n">vendor</span> <span class="n">consume</span> <span class="n">a</span> <span class="n">bun</span> <span class="ow">and</span> <span class="n">a</span> <span class="n">wiener</span><span class="o">.</span>
+ <span class="o">*</span> <span class="n">This</span> <span class="n">method</span> <span class="n">is</span> <span class="n">synchronized</span> <span class="n">to</span> <span class="n">avoid</span> <span class="n">serving</span> <span class="n">to</span> <span class="n">client</span> 
+ <span class="o">*</span> <span class="n">at</span> <span class="n">the</span> <span class="n">same</span> <span class="nb">time</span><span class="o">.</span>
+ <span class="o">*</span> <span class="nv">@return</span> <span class="n">a</span> <span class="n">hotdog</span><span class="o">.</span>
+ <span class="o">*</span> <span class="nv">@see</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">felix</span><span class="o">.</span><span class="n">ipojo</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">vendor</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">Vendor</span><span class="c1">#sell()</span>
+ <span class="o">*/</span>
+<span class="n">public</span> <span class="n">synchronized</span> <span class="n">Product</span> <span class="n">sell</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">bunProvider</span><span class="o">.</span><span class="n">getBun</span><span class="p">();</span>
+    <span class="n">wienerProvider</span><span class="o">.</span><span class="n">getWiener</span><span class="p">();</span>
+    <span class="k">return</span> <span class="k">new</span> <span class="n">HotDog</span><span class="p">();</span>
+<span class="p">}</span>
+
+<span class="n">Once</span> <span class="n">implemented</span><span class="p">,</span> <span class="n">we</span> <span class="n">need</span> <span class="n">to</span> <span class="n">describe</span> <span class="n">this</span> <span class="n">component</span> <span class="n">type</span><span class="o">.</span> <span class="n">The</span> <span class="n">descriptor</span> <span class="n">file</span> <span class="n">is</span> <span class="n">the</span> <span class="n">_metadata</span><span class="o">.</span><span class="n">xml_</span> <span class="n">file</span><span class="o">.</span> <span class="n">The</span> <span class="n">field</span> <span class="n">attributes</span> <span class="n">in</span> <span class="n">the</span> <span class="s">&quot;requires&quot;</span> <span class="n">elements</span> <span class="n">are</span> <span class="n">used</span> <span class="n">to</span> <span class="n">inject</span> <span class="n">the</span> <span class="n">required</span> <span clas
 s="n">services</span><span class="o">.</span> <span class="n">At</span> <span class="n">runtime</span><span class="p">,</span> <span class="n">iPOJO</span> <span class="n">injects</span> <span class="n">automatically</span> <span class="n">a</span> <span class="n">BunService</span> <span class="n">provider</span> <span class="n">in</span> <span class="n">the</span> <span class="s">&quot;bunProvider&quot;</span> <span class="n">field</span> <span class="ow">and</span> <span class="n">a</span> <span class="n">WienerService</span> <span class="n">provider</span> <span class="n">in</span> <span class="n">the</span> <span class="s">&quot;wienerProvider&quot;</span> <span class="n">field</span><span class="o">.</span> <span class="n">The</span> <span class="n">implementation</span> <span class="n">uses</span> <span class="n">these</span> <span class="n">fields</span> <span class="n">the</span> <span class="n">same</span> <span class="n">way</span> <span class="n">it</span> <span c
 lass="n">would</span> <span class="n">have</span> <span class="n">used</span> <span class="n">any</span> <span class="n">other</span> <span class="n">fields</span> <span class="p">(</span><span class="n">as</span> <span class="n">illustrated</span> <span class="n">in</span> <span class="n">the</span> <span class="n">sell</span> <span class="n">method</span><span class="p">)</span><span class="o">.</span>
+<span class="p">{</span><span class="n">code:xml</span><span class="p">}</span>
+<span class="sr">&lt;ipojo&gt;</span>
+<span class="o">&lt;</span><span class="n">component</span> 
+   <span class="n">classname</span><span class="o">=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.hotdog.HotDogVendor&quot;</span>
+   <span class="n">name</span><span class="o">=</span><span class="s">&quot;HD&quot;</span> <span class="n">public</span><span class="o">=</span><span class="s">&quot;false&quot;</span><span class="o">&gt;</span>
+    <span class="sr">&lt;provides/&gt;</span>
+    <span class="o">&lt;</span><span class="n">requires</span> <span class="n">field</span><span class="o">=</span><span class="s">&quot;bunProvider&quot;</span><span class="o">/&gt;</span>
+    <span class="o">&lt;</span><span class="n">requires</span> <span class="n">field</span><span class="o">=</span><span class="s">&quot;wienerProvider&quot;</span><span class="o">/&gt;</span>
+<span class="sr">&lt;/component&gt;</span>
+
+<span class="o">&lt;</span><span class="n">instance</span> <span class="n">component</span><span class="o">=</span><span class="s">&quot;HD&quot;</span><span class="o">/&gt;</span>
+<span class="sr">&lt;/ipojo&gt;</span>
+</pre></div>
+
+
+<p>The component type declares a provided service (the Vendor Service). Then, the component declares the two service dependencies (using the "requires" element). However, we would like to add a service property on the Vendor service describing the sold product (here, "hotdog"). To achieve this, we just need to add a property element in the "provides" tags: </p>
+<div class="codehilite"><pre><span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;component</span> 
+   <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.hotdog.HotDogVendor&quot;</span> 
+   <span class="na">name=</span><span class="s">&quot;HD&quot;</span> <span class="na">public=</span><span class="s">&quot;false&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;provides&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;product&quot;</span> <span class="na">type=</span><span class="s">&quot;string&quot;</span> <span class="na">value=</span><span class="s">&quot;hotdog&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;/provides&gt;</span>
+    <span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;bunProvider&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;wienerProvider&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;HD&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
+
+
+<p>iPOJO then publishes the "product" property in the "vendor" service registration. This property has the "hotdog" value.</p>
+<h2 id="publishing-dynamic-properties">Publishing 'dynamic' properties</h2>
+<p>The bun service and the wiener service can also expose service properties. In our case, these service properties will describe the stock of ingredients. Each time the service is used, the property value is decreased.
+To achieve this, we modify the current implementation to add a field representing the property:</p>
+<p>{code:java}
+public class BunWienerProvider implements BunService, WienerService {</p>
+<div class="codehilite"><pre><span class="n">private</span> <span class="nb">int</span> <span class="n">bunStock</span><span class="p">;</span>
+
+<span class="n">private</span> <span class="nb">int</span> <span class="n">wienerStock</span><span class="p">;</span>
+
+<span class="n">public</span> <span class="n">synchronized</span> <span class="n">void</span> <span class="n">getBun</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">bunStock</span> <span class="o">=</span> <span class="n">bunStock</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">synchronized</span> <span class="n">void</span> <span class="n">getWiener</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">wienerStock</span> <span class="o">=</span> <span class="n">wienerStock</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}</p>
+<div class="codehilite"><pre>The stock accesses are synchronized to avoid multiple accesses at the same time. The component type metadata must also be modified in order to describe this property:
+
+{code:xml}
+<span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;component</span> 
+   <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.provider.BunProvider&quot;</span> 
+   <span class="na">name=</span><span class="s">&quot;buns_and_wieners&quot;</span> <span class="na">public=</span><span class="s">&quot;false&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;provides&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;buns&quot;</span> <span class="na">field=</span><span class="s">&quot;bunStock&quot;</span> <span class="na">value=</span><span class="s">&quot;10&quot;</span><span class="nt">/&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;wieners&quot;</span> <span class="na">field=</span><span class="s">&quot;wienerStock&quot;</span> <span class="na">value=</span><span class="s">&quot;10&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;/provides&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;buns_and_wieners&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
+
+
+<p>In the "provides" element, two properties are added. This property contains a "field" attribute aiming to attach the service property with a field of the implementation class. Then a default value is given. In the code, the property fields will obtain the initial value (10). Then each time the fields are modified, the service property is updated (as well as the OSGi™ service registration). Notice that iPOJO support method injection for property too. In this case, a getter method is called to inject the property value.</p>
+<h2 id="configuring-instances">Configuring instances</h2>
+<p>In the previous example, the properties were configured in the component type description. It is also possible to customize any property value in the instance declaration. This way, each instance can obtain different values.</p>
+<div class="codehilite"><pre><span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;component</span> 
+   <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.provider.BunProvider&quot;</span>
+   <span class="na">name=</span><span class="s">&quot;buns_and_wieners&quot;</span> <span class="na">public=</span><span class="s">&quot;false&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;provides&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;buns&quot;</span> <span class="na">field=</span><span class="s">&quot;bunStock&quot;</span> <span class="na">value=</span><span class="s">&quot;10&quot;</span><span class="nt">/&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;wieners&quot;</span> <span class="na">field=</span><span class="s">&quot;wienerStock&quot;</span> <span class="na">value=</span><span class="s">&quot;10&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;/provides&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;buns_and_wieners&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;buns&quot;</span> <span class="na">value=</span><span class="s">&quot;9&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;wieners&quot;</span> <span class="na">value=</span><span class="s">&quot;8&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
+
+
+<p>The previous metadata shows how to push a configuration in instance declarations. The instance declaration contains two property elements containing the name of the value of the property. Instance configuration override component type initial value. Properties are optional by default ; that's means that they do not need to receive a value. In this case, default values are the same as the Java default fields values (boolean : false, int : 0, double : 0.0d, ...). You can specify that a property must receive a default value from either the component type description or the instance configuration by setting the <code>mandatory</code> attribute to 'true'. </p>
+<h2 id="using-filter-in-service-requirements">Using filter in service requirements</h2>
+<p>Now that bun and wiener providers publish their remaining stock, the hot dog provider can look for a bun service and a wiener service with a non empty stock. To achieve this, we must describe an LDAP filter in the service requirement description. The following XML snipped shows this metadata:</p>
+<div class="codehilite"><pre><span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;component</span> 
+   <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.hotdog.HotDogVendor&quot;</span>
+   <span class="na">name=</span><span class="s">&quot;HD&quot;</span> <span class="na">public=</span><span class="s">&quot;false&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;provides&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;product&quot;</span> <span class="na">type=</span><span class="s">&quot;string&quot;</span> <span class="na">value=</span><span class="s">&quot;hotdog&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;/provides&gt;</span>
+    <span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;bunProvider&quot;</span> <span class="na">filter=</span><span class="s">&quot;(buns&gt;=1)&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;wienerProvider&quot;</span> <span class="na">filter=</span><span class="s">&quot;(wieners&gt;=1)&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;HD&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
 
-    private int wienerStock;
-
-    public synchronized void getBun() {
-        bunStock = bunStock - 1;
-    }
-
-    public synchronized void getWiener() {
-        wienerStock = wienerStock - 1;
-    }
-}
-
-    The stock accesses are synchronized to avoid multiple accesses at the same time. The component type metadata must also be modified in order to describe this property:
-
-    {code:xml}
-    <ipojo>
-    <component 
-       classname="org.apache.felix.ipojo.example.vendor.provider.BunProvider" 
-       name="buns_and_wieners" public="false">
-        <provides>
-            <property name="buns" field="bunStock" value="10"/>
-            <property name="wieners" field="wienerStock" value="10"/>
-        </provides>
-    </component>
-
-    <instance component="buns_and_wieners"/>
-    </ipojo>
-
-In the "provides" element, two properties are added. This property contains a "field" attribute aiming to attach the service property with a field of the implementation class. Then a default value is given. In the code, the property fields will obtain the initial value (10). Then each time the fields are modified, the service property is updated (as well as the OSGi™ service registration). Notice that iPOJO support method injection for property too. In this case, a getter method is called to inject the property value.
-
-## Configuring instances
-
-In the previous example, the properties were configured in the component type description. It is also possible to customize any property value in the instance declaration. This way, each instance can obtain different values.
-
-    <ipojo>
-    <component 
-       classname="org.apache.felix.ipojo.example.vendor.provider.BunProvider"
-       name="buns_and_wieners" public="false">
-        <provides>
-            <property name="buns" field="bunStock" value="10"/>
-            <property name="wieners" field="wienerStock" value="10"/>
-        </provides>
-    </component>
-
-    <instance component="buns_and_wieners">
-        <property name="buns" value="9"/>
-        <property name="wieners" value="8"/>
-    </instance>
-    </ipojo>
-
-The previous metadata shows how to push a configuration in instance declarations. The instance declaration contains two property elements containing the name of the value of the property. Instance configuration override component type initial value. Properties are optional by default ; that's means that they do not need to receive a value. In this case, default values are the same as the Java default fields values (boolean : false, int : 0, double : 0.0d, ...). You can specify that a property must receive a default value from either the component type description or the instance configuration by setting the `mandatory` attribute to 'true'. 
-
-## Using filter in service requirements
-
-Now that bun and wiener providers publish their remaining stock, the hot dog provider can look for a bun service and a wiener service with a non empty stock. To achieve this, we must describe an LDAP filter in the service requirement description. The following XML snipped shows this metadata:
-
-    <ipojo>
-    <component 
-       classname="org.apache.felix.ipojo.example.vendor.hotdog.HotDogVendor"
-       name="HD" public="false">
-        <provides>
-            <property name="product" type="string" value="hotdog"/>
-        </provides>
-        <requires field="bunProvider" filter="(buns>=1)"/>
-        <requires field="wienerProvider" filter="(wieners>=1)"/>
-    </component>
-
-    <instance component="HD"/>
-    </ipojo>
-
-When a provider does no more matches with the LDAP filter, the provider is no more used, and another (matching with the filter) is tracked. If no provider fulfilling the constraint is found, the instance becomes invalid and waits a matching provider.
 
+<p>When a provider does no more matches with the LDAP filter, the provider is no more used, and another (matching with the filter) is tracked. If no provider fulfilling the constraint is found, the instance becomes invalid and waits a matching provider.</p>
 <div class="box">
     <div class="box-blue-header">
     <div class="box-blue-title">
@@ -287,41 +413,38 @@ When an instance becomes invalid, all it
     <div class="box-blue-footer"></div>
 </div>
 
-## Immediate component instance
-
-Now that we get the hot dog provider, we are going to implement customers. Customers are implemented in the *vendor.customer* project). A customer simply looks for a vendor service and buys a product:
-
-{code:java}
-public class Customer {
-
-    private VendorService vendor;
-
-    private String name;
+<h2 id="immediate-component-instance">Immediate component instance</h2>
+<p>Now that we get the hot dog provider, we are going to implement customers. Customers are implemented in the <em>vendor.customer</em> project). A customer simply looks for a vendor service and buys a product:</p>
+<p>{code:java}
+public class Customer {</p>
+<div class="codehilite"><pre>private VendorService vendor;
+
+private String name;
+
+public Customer() {
+    System.out.println(&quot;Customer &quot; + name + &quot; bought &quot; 
+       +  vendor.sell() + &quot; from &quot; + vendor.getName());
+}
 
-    public Customer() {
-        System.out.println("Customer " + name + " bought " 
-           +  vendor.sell() + " from " + vendor.getName());
-    }
-
-    The previous code shows a possible implementation of a customer. However, the "sell" method is called in a constructor, and the constructor can only be called only if an object of the class is created. With iPOJO there are two different way to "activate" an instance as soon as it becomes valid. 
-    The first one uses the lifecycle callback (described in the previous tutorial).  The second one is by declaring the component as an immediate component. An immediate component instance creates an object of its implementation as soon as it becomes valid. 
-
-    {code:xml}
-    <ipojo>
-    <component 
-        classname="org.apache.felix.ipojo.example.vendor.customer.Customer" 
-        name="customer" immediate="true">
-        <requires field="vendor"/>
-        <properties>
-            <property field="name"/>
-        </properties>
-    </component>
-    </ipojo>
+The previous code shows a possible implementation of a customer. However, the &quot;sell&quot; method is called in a constructor, and the constructor can only be called only if an object of the class is created. With iPOJO there are two different way to &quot;activate&quot; an instance as soon as it becomes valid. 
+The first one uses the lifecycle callback (described in the previous tutorial).  The second one is by declaring the component as an immediate component. An immediate component instance creates an object of its implementation as soon as it becomes valid.
 
-To declare a component immediate, just add "immediate=true" in the component descriptor. Then as soon as the vendor service is available, the object is created. Moreover, this type declares a property (to give a name to the customers). This property is not a service property, but just an internal property. As for service properties, the name field will be injected by a value necessary given during the instance creation (i.e. contained inside the instance configuration).
+{code:xml}
+<span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;component</span> 
+    <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.customer.Customer&quot;</span> 
+    <span class="na">name=</span><span class="s">&quot;customer&quot;</span> <span class="na">immediate=</span><span class="s">&quot;true&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;vendor&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;properties&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">field=</span><span class="s">&quot;name&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;/properties&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
 
-By default, all all components that do not provide any service are immediate. Other components create call their constructors when they are used for the first time. 
 
+<p>To declare a component immediate, just add "immediate=true" in the component descriptor. Then as soon as the vendor service is available, the object is created. Moreover, this type declares a property (to give a name to the customers). This property is not a service property, but just an internal property. As for service properties, the name field will be injected by a value necessary given during the instance creation (i.e. contained inside the instance configuration).</p>
+<p>By default, all all components that do not provide any service are immediate. Other components create call their constructors when they are used for the first time. </p>
 <div class="box">
     <div class="box-blue-header">
     <div class="box-blue-title">
@@ -334,231 +457,239 @@ There is a difference between immediate 
     <div class="box-blue-footer"></div>
 </div>
 
-## Creating instances from an external component type
-
-In the previous section we have declared a customer component type, which does not have the "public=false" attribute. This feature allows separate deployment from instance creation. Moreover, we didn't declare instances in the descriptor. 
-Another metadata file can be used to declare instances from the customer type, this descriptor being contained in another bundle. The following descriptor creates 10 customer instances (look at the *vendor.customer.creator\metadata.xml* file):
-
-    <ipojo>
-    <instance component="customer">
-        <property name="name" value="customer-1"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-2"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-3"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-4"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-5"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-6"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-7"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-8"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-9"/>
-    </instance>
-    <instance component="customer">
-        <property name="name" value="customer-10"/>
-    </instance>
-    </ipojo>
-
-Once deployed, this bundle looks for the required factory. If it's not available the bundle waits for the factory. As soon as the required factory is available, all instances are created. When this bundle is stopped, all instances are destroyed. 
-## Deploying the application
-Compile the bundles, by launching ant at the root of the tutorial. Then launch Felix is indicated above. 
+<h2 id="creating-instances-from-an-external-component-type">Creating instances from an external component type</h2>
+<p>In the previous section we have declared a customer component type, which does not have the "public=false" attribute. This feature allows separate deployment from instance creation. Moreover, we didn't declare instances in the descriptor. 
+Another metadata file can be used to declare instances from the customer type, this descriptor being contained in another bundle. The following descriptor creates 10 customer instances (look at the <em>vendor.customer.creator\metadata.xml</em> file):</p>
+<div class="codehilite"><pre><span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-1&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-2&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-3&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-4&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-5&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-6&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-7&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-8&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-9&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;customer&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">value=</span><span class="s">&quot;customer-10&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
+
+
+<p>Once deployed, this bundle looks for the required factory. If it's not available the bundle waits for the factory. As soon as the required factory is available, all instances are created. When this bundle is stopped, all instances are destroyed. </p>
+<h2 id="deploying-the-application">Deploying the application</h2>
+<p>Compile the bundles, by launching ant at the root of the tutorial. Then launch Felix is indicated above. 
 Once started, launch the following commands 
 {code:none}
 start file:../vendor.services/output/vendor.services.jar
 start file:../vendor.buns-and-wieners/output/vendor.buns-and-wieners.jar
 start file:../vendor.hotdog/output/vendor.hotdog.jar
 start file:../vendor.customer/output/vendor.customer.jar
-start file:../vendor.customer.creator/output/vendor.customer.creator.jar
-
-    Something like this should appear:
-    {code:none}
-    Customer customer-1 bought Hotdog from Fenway Park
-    Customer customer-2 bought Hotdog from Fenway Park
-    Customer customer-3 bought Hotdog from Fenway Park
-    Customer customer-4 bought Hotdog from Fenway Park
-    Customer customer-5 bought Hotdog from Fenway Park
-    Customer customer-6 bought Hotdog from Fenway Park
-    Customer customer-7 bought Hotdog from Fenway Park
-    Customer customer-8 bought Hotdog from Fenway Park
-
-Only 8 customers can buy a hot-dog, as the stock of wieners and buns can't supply more hot-dog. The remainder of this tutorial will try to solve the problem of these two hungry customers.
-## Using the lifecycle controller
-Sometimes you want to invalidate your instance in the code (for example: to unregister a service). That's possible with the lifecycle controller handler.
-Let's take the popcorn vendor with a corn stock from the *vendor.popcorn* project. Each time it sells some popcorn, its stock is decreased. When the stock reaches 0, it cannot sell popcorns any more (so the vendor service needs to be withdrawn).
-
-The following implementation (*src\org\apache\felix\ipojo\example\vendor\popcorn\PopCornVendor.java*) uses a field to control the lifecycle.
-
-{code:java}
-/**
+start file:../vendor.customer.creator/output/vendor.customer.creator.jar</p>
+<div class="codehilite"><pre><span class="n">Something</span> <span class="n">like</span> <span class="n">this</span> <span class="n">should</span> <span class="n">appear:</span>
+<span class="p">{</span><span class="n">code:none</span><span class="p">}</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">1</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">2</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">3</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">4</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">5</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">6</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">7</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">8</span> <span class="n">bought</span> <span class="n">Hotdog</span> <span class="n">from</span> <span class="n">Fenway</span> <span class="n">Park</span>
+</pre></div>
+
+
+<p>Only 8 customers can buy a hot-dog, as the stock of wieners and buns can't supply more hot-dog. The remainder of this tutorial will try to solve the problem of these two hungry customers.</p>
+<h2 id="using-the-lifecycle-controller">Using the lifecycle controller</h2>
+<p>Sometimes you want to invalidate your instance in the code (for example: to unregister a service). That's possible with the lifecycle controller handler.
+Let's take the popcorn vendor with a corn stock from the <em>vendor.popcorn</em> project. Each time it sells some popcorn, its stock is decreased. When the stock reaches 0, it cannot sell popcorns any more (so the vendor service needs to be withdrawn).</p>
+<p>The following implementation (<em>src\org\apache\felix\ipojo\example\vendor\popcorn\PopCornVendor.java</em>) uses a field to control the lifecycle.</p>
+<p>{code:java}
+/<em><em>
      * The corn stock.
-     */
-    private int m*corn*stock;
-
-    /**
-     * Lifecycle controller.
-     * If set to false, the instance becomes invalid. 
-     */
-    private boolean m*can*sell = true;
-
-    /**
-     * The sell method.
-     * To provide popcorn, the vendor needs to decrease its corn stock level.
-     * This method is synchronized to avoid to client being serve at 
-     * the same time. 
-     * @return
-     * @see org.apache.felix.ipojo.example.vendor.service.Vendor#sell()
-     */
-
-    public synchronized Product sell() {
-        m*corn*stock--;
-        if (m*corn*stock == 0 && m*can*sell) { // Last pop corn
-            m*can*sell = false;
-            System.out.println("Stop selling popcorn 
-                  ... Run out of stock");
-            return new PopCorn();
-        } else if (m*corn*stock > 0) { // Normal case
-            return new PopCorn();
-        } else { // Cannot serve.
-            return PopCorn.NO*MORE*POPCORN;
-        }
-    }
+   <br />
+</em>/
+    private int m</em>corn*stock;</p>
+<div class="codehilite"><pre><span class="o">/**</span>
+ <span class="o">*</span> <span class="n">Lifecycle</span> <span class="n">controller</span><span class="o">.</span>
+ <span class="o">*</span> <span class="n">If</span> <span class="n">set</span> <span class="n">to</span> <span class="n">false</span><span class="p">,</span> <span class="n">the</span> <span class="n">instance</span> <span class="n">becomes</span> <span class="n">invalid</span><span class="o">.</span> 
+ <span class="o">*/</span>
+<span class="n">private</span> <span class="n">boolean</span> <span class="n">m</span><span class="o">*</span><span class="n">can</span><span class="o">*</span><span class="n">sell</span> <span class="o">=</span> <span class="n">true</span><span class="p">;</span>
+
+<span class="o">/**</span>
+ <span class="o">*</span> <span class="n">The</span> <span class="n">sell</span> <span class="n">method</span><span class="o">.</span>
+ <span class="o">*</span> <span class="n">To</span> <span class="n">provide</span> <span class="n">popcorn</span><span class="p">,</span> <span class="n">the</span> <span class="n">vendor</span> <span class="n">needs</span> <span class="n">to</span> <span class="n">decrease</span> <span class="n">its</span> <span class="n">corn</span> <span class="n">stock</span> <span class="n">level</span><span class="o">.</span>
+ <span class="o">*</span> <span class="n">This</span> <span class="n">method</span> <span class="n">is</span> <span class="n">synchronized</span> <span class="n">to</span> <span class="n">avoid</span> <span class="n">to</span> <span class="n">client</span> <span class="n">being</span> <span class="n">serve</span> <span class="n">at</span> 
+ <span class="o">*</span> <span class="n">the</span> <span class="n">same</span> <span class="nb">time</span><span class="o">.</span> 
+ <span class="o">*</span> <span class="nv">@return</span>
+ <span class="o">*</span> <span class="nv">@see</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">felix</span><span class="o">.</span><span class="n">ipojo</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">vendor</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">Vendor</span><span class="c1">#sell()</span>
+ <span class="o">*/</span>
+
+<span class="n">public</span> <span class="n">synchronized</span> <span class="n">Product</span> <span class="n">sell</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">m</span><span class="o">*</span><span class="n">corn</span><span class="o">*</span><span class="n">stock</span><span class="o">--</span><span class="p">;</span>
+    <span class="k">if</span> <span class="p">(</span><span class="n">m</span><span class="o">*</span><span class="n">corn</span><span class="o">*</span><span class="n">stock</span> <span class="o">==</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span> <span class="n">m</span><span class="o">*</span><span class="n">can</span><span class="o">*</span><span class="n">sell</span><span class="p">)</span> <span class="p">{</span> <span class="sr">//</span> <span class="n">Last</span> <span class="nb">pop</span> <span class="n">corn</span>
+        <span class="n">m</span><span class="o">*</span><span class="n">can</span><span class="o">*</span><span class="n">sell</span> <span class="o">=</span> <span class="n">false</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;Stop selling popcorn </span>
+<span class="s">              ... Run out of stock&quot;</span><span class="p">);</span>
+        <span class="k">return</span> <span class="k">new</span> <span class="n">PopCorn</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">m</span><span class="o">*</span><span class="n">corn</span><span class="o">*</span><span class="n">stock</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="sr">//</span> <span class="n">Normal</span> <span class="k">case</span>
+        <span class="k">return</span> <span class="k">new</span> <span class="n">PopCorn</span><span class="p">();</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="sr">//</span> <span class="n">Cannot</span> <span class="n">serve</span><span class="o">.</span>
+        <span class="k">return</span> <span class="n">PopCorn</span><span class="o">.</span><span class="n">NO</span><span class="o">*</span><span class="n">MORE</span><span class="o">*</span><span class="n">POPCORN</span><span class="p">;</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+
+<span class="n">Once</span> <span class="n">the</span> <span class="n">field</span> <span class="n">is</span> <span class="n">set</span> <span class="n">to</span> <span class="s">&quot;false&quot;</span><span class="p">,</span> <span class="n">the</span> <span class="n">instance</span> <span class="n">is</span> <span class="n">invalidated</span> <span class="p">(</span><span class="n">the</span> <span class="n">vendor</span> <span class="n">service</span> <span class="n">is</span> <span class="nb">no</span> <span class="n">more</span> <span class="n">available</span><span class="p">)</span><span class="o">.</span> <span class="n">To</span> <span class="n">configure</span> <span class="n">the</span> <span class="n">controller</span><span class="p">,</span> <span class="n">you</span> <span class="n">can</span> <span class="k">use</span> <span class="n">the</span> <span class="n">following</span> <span class="n">metadata:</span>
+<span class="p">{</span><span class="n">code:xml</span><span class="p">}</span>
+<span class="sr">&lt;ipojo&gt;</span>
+<span class="o">&lt;</span><span class="n">component</span> 
+    <span class="n">classname</span><span class="o">=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.popcorn.PopCornVendor&quot;</span>
+    <span class="n">name</span><span class="o">=</span><span class="s">&quot;popcorn&quot;</span> <span class="n">public</span><span class="o">=</span><span class="s">&quot;false&quot;</span> <span class="n">architecture</span><span class="o">=</span><span class="s">&quot;true&quot;</span><span class="o">&gt;</span>
+    <span class="sr">&lt;provides/&gt;</span>
+    <span class="o">&lt;</span><span class="n">controller</span> <span class="n">field</span><span class="o">=</span><span class="s">&quot;m_can_sell&quot;</span><span class="o">/&gt;</span>
+<span class="sr">&lt;/component&gt;</span>
+
+<span class="o">&lt;</span><span class="n">instance</span> <span class="n">component</span><span class="o">=</span><span class="s">&quot;popcorn&quot;</span><span class="o">/&gt;</span>
+<span class="sr">&lt;/ipojo&gt;</span>
+</pre></div>
 
-    Once the field is set to "false", the instance is invalidated (the vendor service is no more available). To configure the controller, you can use the following metadata:
-    {code:xml}
-    <ipojo>
-    <component 
-        classname="org.apache.felix.ipojo.example.vendor.popcorn.PopCornVendor"
-        name="popcorn" public="false" architecture="true">
-        <provides/>
-        <controller field="m_can_sell"/>
-    </component>
 
-    <instance component="popcorn"/>
-    </ipojo>
-
-The instance can be re-validated by setting the field to true.
+<p>The instance can be re-validated by setting the field to true.
 So, no deploy the pop corn vendor.
 {code:none}
--> start file:../vendor.popcorn/output/vendor.popcorn.jar
-Customer customer-10 bought popcorn from D & P
-Customer customer-9 bought popcorn from D & P
-
-    Our two last customers are no more hungry. However, new customers arrives, we have the following situation:
-    {code:none}
-    -> update 10
-    Customer customer-1 bought popcorn from D & P
-    Customer customer-2 bought popcorn from D & P
-    Stop selling popcorn ... Run out of stock
-    Customer customer-3 bought popcorn from D & P
-
-To recreate new customers, just update the customer.creator bundle (bundle 10). So, now we have 7 customers hungry! There is neither popcorn nor hotdog!
-## Reconfiguring an instance
-OSGi specified the Configuration Admin mechanism aiming to handler service and bundle configuration. This section will describe how you can use the Configuration Admin and iPOJO to add corn inside our popcorn vendor.
+-&gt; start file:../vendor.popcorn/output/vendor.popcorn.jar
+Customer customer-10 bought popcorn from D &amp; P
+Customer customer-9 bought popcorn from D &amp; P</p>
+<div class="codehilite"><pre><span class="n">Our</span> <span class="n">two</span> <span class="k">last</span> <span class="n">customers</span> <span class="n">are</span> <span class="nb">no</span> <span class="n">more</span> <span class="n">hungry</span><span class="o">.</span> <span class="n">However</span><span class="p">,</span> <span class="k">new</span> <span class="n">customers</span> <span class="n">arrives</span><span class="p">,</span> <span class="n">we</span> <span class="n">have</span> <span class="n">the</span> <span class="n">following</span> <span class="n">situation:</span>
+<span class="p">{</span><span class="n">code:none</span><span class="p">}</span>
+<span class="o">-&gt;</span> <span class="n">update</span> <span class="mi">10</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">1</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">2</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Stop</span> <span class="n">selling</span> <span class="n">popcorn</span> <span class="o">...</span> <span class="n">Run</span> <span class="n">out</span> <span class="n">of</span> <span class="n">stock</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">3</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+</pre></div>
+
+
+<p>To recreate new customers, just update the customer.creator bundle (bundle 10). So, now we have 7 customers hungry! There is neither popcorn nor hotdog!</p>
+<h2 id="reconfiguring-an-instance">Reconfiguring an instance</h2>
+<p>OSGi specified the Configuration Admin mechanism aiming to handler service and bundle configuration. This section will describe how you can use the Configuration Admin and iPOJO to add corn inside our popcorn vendor.
 First, we will change the pop corn vendor to add a method reinjecting the new stock:
 {code:java}
-/**
+/<em><em>
      * A transporter refills the stock of corn.
      * This method is synchronized to avoid to client being served 
      * during the update.
      * @param newStock : the stock of corn to add to the current stock.
-     */
+   <br />
+</em>/
     public synchronized void refillStock(int newStock) {
-        m*corn*stock += newStock;
-        System.out.println("Refill the stock : " + m*corn*stock);
-        if (m*corn*stock > 0) {
-            m*can*sell = true;
+        m</em>corn<em>stock += newStock;
+        System.out.println("Refill the stock : " + m</em>corn<em>stock);
+        if (m</em>corn<em>stock &gt; 0) {
+            m</em>can*sell = true;
         }
-    }
+    }</p>
+<div class="codehilite"><pre>Once added, we need to update the component type descriptor to use this method:
+{code:xml}
+<span class="nt">&lt;ipojo&gt;</span>
+<span class="nt">&lt;component</span> 
+    <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.example.vendor.popcorn.PopCornVendor&quot;</span> 
+    <span class="na">name=</span><span class="s">&quot;popcorn&quot;</span> <span class="na">architecture=</span><span class="s">&quot;true&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;provides/&gt;</span>
+    <span class="nt">&lt;controller</span> <span class="na">field=</span><span class="s">&quot;m_can_sell&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;properties&gt;</span>
+        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;stock&quot;</span> <span class="na">method=</span><span class="s">&quot;refillStock&quot;</span> <span class="na">value=</span><span class="s">&quot;5&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;/properties&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+
+<span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;popcorn&quot;</span> <span class="na">name=</span><span class="s">&quot;SuperPopCorn&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;managed.service.pid&quot;</span> <span class="na">value=</span><span class="s">&quot;Super.PopCorn.Stock&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+<span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
 
-    Once added, we need to update the component type descriptor to use this method:
-    {code:xml}
-    <ipojo>
-    <component 
-        classname="org.apache.felix.ipojo.example.vendor.popcorn.PopCornVendor" 
-        name="popcorn" architecture="true">
-        <provides/>
-        <controller field="m_can_sell"/>
-        <properties>
-            <property name="stock" method="refillStock" value="5"/>
-        </properties>
-    </component>
-
-    <instance component="popcorn" name="SuperPopCorn">
-        <property name="managed.service.pid" value="Super.PopCorn.Stock"/>
-    </instance>
-    </ipojo>
 
-We add two different things. First we add a "stock" property attached to the *refillStock* method. When this instance is configured or reconfigured, this method is called to push the new stock value. Then we add the *managed.service.pid* property inside the instance creation. This property will be used by the Configuration Admin to attach configuration to instances. The property value must be unique.
+<p>We add two different things. First we add a "stock" property attached to the <em>refillStock</em> method. When this instance is configured or reconfigured, this method is called to push the new stock value. Then we add the <em>managed.service.pid</em> property inside the instance creation. This property will be used by the Configuration Admin to attach configuration to instances. The property value must be unique.
 So now, our popcorn vendor can be reconfigured dynamically to get increments its corn stock.
 However, we need to create something refilling the stock ... a corn transporter !
-Inside the *vendor.corn.transporter* project, we have a component dealing with the ConfigurationAdmin to push the new pop corn vendor configuration.
-The implementation is contained in the *src\org\apache\felix\ipojo\example\vendor\corn\transporter\CornTransporter.java* file.
+Inside the <em>vendor.corn.transporter</em> project, we have a component dealing with the ConfigurationAdmin to push the new pop corn vendor configuration.
+The implementation is contained in the <em>src\org\apache\felix\ipojo\example\vendor\corn\transporter\CornTransporter.java</em> file.
 {code:java}
-public class CornTransporter {
-
-    private ConfigurationAdmin m_configAdmin;
-
-    /**
-     * Reconfigure the popcorn vendor with the configuration admin. 
-     */
-    public void refillStock() {
-        try {
-            // Retrieve or Create the instance configuration
-            // from the configuration admin
-            Configuration configuration = 
-                 m_configAdmin.getConfiguration("Super.PopCorn.Stock", 
-                 "file:../vendor.popcorn/output/vendor.popcorn.jar");
-            configuration.setBundleLocation(
-                 "file:../vendor.popcorn/output/vendor.popcorn.jar");
-            Properties props = new Properties();
-            props.put("stock", new Integer(15)); // Delivered corn
-            configuration.update(props);
-            System.out.println("Update the configuration of " 
-                  + configuration.getPid() + "(" 
-                  + configuration.getBundleLocation() + ")");
-            configuration.delete();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-}
-
-    Create a new configuration from the configuration admin and configure this configuration to add corn. Then, we update this configuration. This will reconfigured our popcorn vendor. More information on the Configuration Admin is available in the OSGi R4 Compendium.
-    So, now if we deploy this bundle, we will provide enough corn to feed all the customers:
-    {code:none}
-    -> start file:../vendor.corn.transporter/output/vendor.corn.transporter.jar
-    Update configuration of Super.PopCorn.Stock(
-           file:../vendor.popcorn/output/vendor.popcorn.jar)
-    Refill the stock : 5
-    Customer customer-10 bought popcorn from D & P
-    Customer customer-9 bought popcorn from D & P
-    Customer customer-8 bought popcorn from D & P
-    Customer customer-7 bought popcorn from D & P
-    Customer customer-6 bought popcorn from D & P
-    Customer customer-5 bought popcorn from D & P
-    Customer customer-4 bought popcorn from D & P
+public class CornTransporter {</p>
+<div class="codehilite"><pre><span class="n">private</span> <span class="n">ConfigurationAdmin</span> <span class="n">m_configAdmin</span><span class="p">;</span>
 
-That's it!
-
-## Conclusion
-This small tutorial has presented some of of the iPOJO features. Subscribe to the Felix users mailing list by sending a message to [mailto:users-subscribe@felix.apache.org](); after subscribing, email questions or feedback to [mailto:users@felix.apache.org].
+<span class="o">/**</span>
+ <span class="o">*</span> <span class="n">Reconfigure</span> <span class="n">the</span> <span class="n">popcorn</span> <span class="n">vendor</span> <span class="n">with</span> <span class="n">the</span> <span class="n">configuration</span> <span class="n">admin</span><span class="o">.</span> 
+ <span class="o">*/</span>
+<span class="n">public</span> <span class="n">void</span> <span class="n">refillStock</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">try</span> <span class="p">{</span>
+        <span class="sr">//</span> <span class="n">Retrieve</span> <span class="ow">or</span> <span class="n">Create</span> <span class="n">the</span> <span class="n">instance</span> <span class="n">configuration</span>
+        <span class="sr">//</span> <span class="n">from</span> <span class="n">the</span> <span class="n">configuration</span> <span class="n">admin</span>
+        <span class="n">Configuration</span> <span class="n">configuration</span> <span class="o">=</span> 
+             <span class="n">m_configAdmin</span><span class="o">.</span><span class="n">getConfiguration</span><span class="p">(</span><span class="s">&quot;Super.PopCorn.Stock&quot;</span><span class="p">,</span> 
+             <span class="s">&quot;file:../vendor.popcorn/output/vendor.popcorn.jar&quot;</span><span class="p">);</span>
+        <span class="n">configuration</span><span class="o">.</span><span class="n">setBundleLocation</span><span class="p">(</span>
+             <span class="s">&quot;file:../vendor.popcorn/output/vendor.popcorn.jar&quot;</span><span class="p">);</span>
+        <span class="n">Properties</span> <span class="n">props</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Properties</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;stock&quot;</span><span class="p">,</span> <span class="k">new</span> <span class="n">Integer</span><span class="p">(</span><span class="mi">15</span><span class="p">));</span> <span class="sr">//</span> <span class="n">Delivered</span> <span class="n">corn</span>
+        <span class="n">configuration</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">props</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;Update the configuration of &quot;</span> 
+              <span class="o">+</span> <span class="n">configuration</span><span class="o">.</span><span class="n">getPid</span><span class="p">()</span> <span class="o">+</span> <span class="s">&quot;(&quot;</span> 
+              <span class="o">+</span> <span class="n">configuration</span><span class="o">.</span><span class="n">getBundleLocation</span><span class="p">()</span> <span class="o">+</span> <span class="s">&quot;)&quot;</span><span class="p">);</span>
+        <span class="n">configuration</span><span class="o">.</span><span class="nb">delete</span><span class="p">();</span>
+    <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">IOException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">e</span><span class="o">.</span><span class="n">printStackTrace</span><span class="p">();</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}</p>
+<div class="codehilite"><pre><span class="n">Create</span> <span class="n">a</span> <span class="k">new</span> <span class="n">configuration</span> <span class="n">from</span> <span class="n">the</span> <span class="n">configuration</span> <span class="n">admin</span> <span class="ow">and</span> <span class="n">configure</span> <span class="n">this</span> <span class="n">configuration</span> <span class="n">to</span> <span class="n">add</span> <span class="n">corn</span><span class="o">.</span> <span class="n">Then</span><span class="p">,</span> <span class="n">we</span> <span class="n">update</span> <span class="n">this</span> <span class="n">configuration</span><span class="o">.</span> <span class="n">This</span> <span class="n">will</span> <span class="n">reconfigured</span> <span class="k">our</span> <span class="n">popcorn</span> <span class="n">vendor</span><span class="o">.</span> <span class="n">More</span> <span class="n">information</span> <span class="n">on</span>
  <span class="n">the</span> <span class="n">Configuration</span> <span class="n">Admin</span> <span class="n">is</span> <span class="n">available</span> <span class="n">in</span> <span class="n">the</span> <span class="n">OSGi</span> <span class="n">R4</span> <span class="n">Compendium</span><span class="o">.</span>
+<span class="n">So</span><span class="p">,</span> <span class="n">now</span> <span class="k">if</span> <span class="n">we</span> <span class="n">deploy</span> <span class="n">this</span> <span class="n">bundle</span><span class="p">,</span> <span class="n">we</span> <span class="n">will</span> <span class="n">provide</span> <span class="n">enough</span> <span class="n">corn</span> <span class="n">to</span> <span class="n">feed</span> <span class="n">all</span> <span class="n">the</span> <span class="n">customers:</span>
+<span class="p">{</span><span class="n">code:none</span><span class="p">}</span>
+<span class="o">-&gt;</span> <span class="n">start</span> <span class="n">file:</span><span class="o">..</span><span class="sr">/vendor.corn.transporter/o</span><span class="n">utput</span><span class="o">/</span><span class="n">vendor</span><span class="o">.</span><span class="n">corn</span><span class="o">.</span><span class="n">transporter</span><span class="o">.</span><span class="n">jar</span>
+<span class="n">Update</span> <span class="n">configuration</span> <span class="n">of</span> <span class="n">Super</span><span class="o">.</span><span class="n">PopCorn</span><span class="o">.</span><span class="n">Stock</span><span class="p">(</span>
+       <span class="n">file:</span><span class="o">..</span><span class="sr">/vendor.popcorn/o</span><span class="n">utput</span><span class="o">/</span><span class="n">vendor</span><span class="o">.</span><span class="n">popcorn</span><span class="o">.</span><span class="n">jar</span><span class="p">)</span>
+<span class="n">Refill</span> <span class="n">the</span> <span class="n">stock</span> <span class="p">:</span> <span class="mi">5</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">10</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">9</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">8</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">7</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">6</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">5</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+<span class="n">Customer</span> <span class="n">customer</span><span class="o">-</span><span class="mi">4</span> <span class="n">bought</span> <span class="n">popcorn</span> <span class="n">from</span> <span class="n">D</span> <span class="o">&amp;</span> <span class="n">P</span>
+</pre></div>
+
+
+<p>That's it!</p>
+<h2 id="conclusion">Conclusion</h2>

[... 32 lines stripped ...]


Mime
View raw message