You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by bu...@apache.org on 2013/02/03 07:45:22 UTC

svn commit: r849204 [21/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/apac...

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/providing-osgi-services.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/providing-osgi-services.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/providing-osgi-services.html Sun Feb  3 06:45:21 2013
@@ -20,9 +20,45 @@
   <head>
     <title>Apache Felix - Providing OSGi services</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,98 +73,189 @@
         </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-userguide.html">apache-felix-ipojo-userguide</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components.html">Describing components</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/providing-osgi-services.html" target="felix_cwiki">/site/providing-osgi-services.html</a>. In case of
            doubt you might want to refer to the old page.
       </div>
       
+      -->
       
       <h1>Providing OSGi services</h1>
-      <p>{include:apache-felix-ipojo-header}</p>
-<div class="content">
-
-# Providing OSGi services
-
-*This pages explains how to publish OSGi services with iPOJO. It presents:*
-* *service publication*
-* *service properties publication and management*
-* *service object creation and creation strategies*
-* *service un-registration*
-* *configuration property propagation*
-* *the management of the exposition from the implementation class*
-
-{div:class=toc}
+      
+      <div class="content">
+        <h1 id="providing-osgi-services">Providing OSGi services</h1>
+<p><em>This pages explains how to publish OSGi services with iPOJO. It presents:</em>
+<em> </em>service publication<em>
+</em> <em>service properties publication and management</em>
+<em> </em>service object creation and creation strategies<em>
+</em> <em>service un-registration</em>
+<em> </em>configuration property propagation<em>
+</em> <em>the management of the exposition from the implementation class</em></p>
+<p>{div:class=toc}
 [TOC]
-{div}
-
-## A simple example
-
-The following code snippet shows a simple class implementing the `FooService` interface:
-
-    @Component
-    @Provides
-    public class FooProviderType1 implements FooService {
-                private String m_foo = "foo";
-
-                public void foo() {
-                            System.out.println("foo  " + m_foo);
-                }
-
-    }
-
-To provide a service, the implementation class *MUST* implement the service interface. 
-
-In XML, to provide the service, the component type needs to contain the `<provides/>` element:
-
-    <component className="...FooProviderType1">
-            <provides/>
-    </component>
+{div}</p>
+<h2 id="a-simple-example">A simple example</h2>
+<p>The following code snippet shows a simple class implementing the <code>FooService</code> interface:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">FooProviderType1</span> <span class="n">implements</span> <span class="n">FooService</span> <span class="p">{</span>
+            <span class="n">private</span> <span class="n">String</span> <span class="n">m_foo</span> <span class="o">=</span> <span class="s">&quot;foo&quot;</span><span class="p">;</span>
+
+            <span class="n">public</span> <span class="n">void</span> <span class="n">foo</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;foo  &quot;</span> <span class="o">+</span> <span class="n">m_foo</span><span class="p">);</span>
+            <span class="p">}</span>
+
+<span class="p">}</span>
+</pre></div>
+
+
+<p>To provide a service, the implementation class <em>MUST</em> implement the service interface. </p>
+<p>In XML, to provide the service, the component type needs to contain the <code>&lt;provides/&gt;</code> element:</p>
+<div class="codehilite"><pre><span class="nt">&lt;component</span> <span class="na">className=</span><span class="s">&quot;...FooProviderType1&quot;</span><span class="nt">&gt;</span>
+        <span class="nt">&lt;provides/&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+</pre></div>
+
+
+<p>!ps-foo.png!</p>
+<p>The <code>&lt;provides/&gt;</code> or <code>@Provides</code> suffice to declare that each instance of this type will provide the FooService (for more info about instances see <a href="">FELIX:How-to use iPOJO factories</a>). The provided specifications can be discovered by analyzing the implementation class. By default, all implemented interface are published in the same service registration. iPOJO looks down the entire inheritance tree.</p>
+<h2 id="service-publication">Service Publication</h2>
+<p>The provided service handler manages service publication. For each declared <code>&lt;provides/&gt;</code>, the handler registers a service. Since the <code>@Provides</code> annotation can be used only once, only one service is registered that provides all interfaces. The service is published as long as the instance is valid. If the instance becomes invalid, the service is removed from the service registry.</p>
+<p>By default, it publishes all interfaces implemented by the implementation class of the component class. It collects all super-interfaces (interfaces implemented by implemented interfaces and by the super class). However, it is possible to explicitly declare which service specifications are published with the <code>specifications</code> attribute, such as:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span><span class="p">(</span><span class="n">specifications</span><span class="o">=</span><span class="p">{</span><span class="n">FooService</span><span class="o">.</span><span class="n">class</span><span class="p">})</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">FooProviderType1</span> <span class="n">implements</span> <span class="n">FooService</span><span class="p">,</span> <span class="n">Runnable</span> <span class="p">{</span>
+    <span class="sr">//</span> <span class="o">...</span>
+<span class="p">}</span>
+</pre></div>
 
-!ps-foo.png!
-
-The `<provides/>` or `@Provides` suffice to declare that each instance of this type will provide the FooService (for more info about instances see [FELIX:How-to use iPOJO factories]()). The provided specifications can be discovered by analyzing the implementation class. By default, all implemented interface are published in the same service registration. iPOJO looks down the entire inheritance tree.
-
-## Service Publication
-
-The provided service handler manages service publication. For each declared `<provides/>`, the handler registers a service. Since the `@Provides` annotation can be used only once, only one service is registered that provides all interfaces. The service is published as long as the instance is valid. If the instance becomes invalid, the service is removed from the service registry.
-
-By default, it publishes all interfaces implemented by the implementation class of the component class. It collects all super-interfaces (interfaces implemented by implemented interfaces and by the super class). However, it is possible to explicitly declare which service specifications are published with the `specifications` attribute, such as:
-
-    @Component
-    @Provides(specifications={FooService.class})
-    public class FooProviderType1 implements FooService, Runnable {
-        // ...
-    }
 
 <div class="info" markdown="1">
 **Change in the 1.2.0**
@@ -145,306 +272,311 @@ If you use the `specifications` attribut
 If the implementation class does not implement any interface, you cannot provide a service. In this case, the handler throws an error.
 </div>
 
-## Service Properties
-
-You can also attach properties to a service registration. Service properties are attached to published service and allow consumer filtering/selecting providers. A property can be attached to a field (contained in the component implementation class), and so can be handle dynamically.
-
-Let's take a new example very closed of the last one:
-
-    @Component
-    @Provides
-    public class FooProviderType1 implements FooService {
-
-        @ServiceProperty(name="foo", value="Foo")
-        private String m_foo;
-
-        public void foo() {
-            System.out.println("foo  " + m_foo);
-            m_foo = "bar";
-        }
-    }
-
-Using XML, it gives:
-
-    <component classname="...FooProviderType1">
-                <provides>
-                            <property name="foo" field="m_foo" value="Foo"/>
-                </provides>
-    </component>
-
-The declared property is attached to the `m*foo` field. This property is published with the name `foo`. This property has a default value "Foo". This value will be injected into the `m*foo` field, when this field asks for a value. A property with a field attribute does not need to declare a type (the type can be discovered by analyzing the implementation class).
-
-The implementation class set a new value to the `m_foo` field in the code. When this action occurs, the service publication is updated. If a published property value becomes `null`, the property is unpublished since it has a new value.
-
-You can also publish 'static' properties (not attached to a field):
-
-    @Component
-    @Provides(properties= {
-                @StaticServiceProperty(name="static", type="java.lang.String", value="this is a static property")
-        })
-    public class FooProviderType1 implements FooService {
-
-        @ServiceProperty(name="foo", value="Foo")
-        private String m_foo;
-
-        public void foo() {
-            System.out.println("foo  " + m_foo);
-            m_foo = "bar";
-        }
-    }
-
-The second property (`Static`) is published as a static property. This property is not attached to a field, so, we need to declare the property type. All primitive types or objects can be used has property type (for object, the qualified name of the class is used as java.lang.String).
-
-In XML, this can also be done:
-
-    <component classname="...FooProviderType1">
-                <provides>
-                            <property name="foo" field="m_foo" value="Foo"/>
-                            <property name="static" type="java.lang.String" value="this is a static property"/>
-                </provides>
-    </component>
-
-Properties may have a default value (set using the `value` attribute). This value will be used as initial value. The value can be given in the instance configuration. The default value will be overridden in this case:
-
-    <instance component="...FooProviderType1">
-       <property name="foo" value="My New Foo Value"/>
-       <property name="static" value="My Value For Static"/>
-    </instance>
-
-Properties can also be 'mandatory'. Mandatories properties must receive a value from the instance configuration. If the instance configuration *forgets* a mandatory properties, the configuration is rejected. Mandatory attribute let you be sure to receive the complete set of initialization values:
-
-    @Component
-    @Provides
-    public class MyComponent implements MyService {
-
-        @ServiceProperty(name="username", mandatory=true)
-        private String m_username;
-
-        @Property(name="password", mandatory=true)
-        private String m_password;
-
-        //...
-    }
-
-For the previous components:
-* `(name=myname, password=****)` is a valid configuration
-* `(password=****)` is an invalid configuration that will be rejected by iPOJO
-
-## Advanced features
-
-### Service Serving & Object Creation
-
-When a consumer requires the published service, the handler sends an object (from the component class) of the implementation class. By default, it is always the same POJO object. If no objects already exists, an instance is created.
-
-However, the handler supports the OSGi *Service Factory*. In this case, for each requester bundle, the handler sends a new object. To activate this policy, add the `strategy` attribute in the `provides` element:
-
-    @Component
-    @Provides(strategy="SERVICE")
-    public class MyComponent implements MyService {
-        //...
-    }
-
-or:
-
-    <provides strategy="SERVICE"/>
-
-Other strategies are available:
- * `strategy="instance"` allows creating one service object per iPOJO instance using the service
- * it is possible to create your own creation strategy by extending the `org.apache.felix.ipojo.handlers.providedservice.CreationStrategy` class and by indicating the qualified class name in the `strategy` attribute:
-
-    @Component
-    @Provides(strategy="org.acme.foo.MyCreationStrategy")
-    public class MyComponent implements MyService {
-        //...
-    }
-
-### Providing Several Services (XML only)
-In XML, you can declare several `provides` inside the same component. All those provided services will be managed individually, so will be published using several publication (i.e. `org.osgi.frameowrk.ServiceRegistration`). This case is useful when service properties are different for the different services.
-
-    <component classname="...FooProviderType1">
-                    <provides specifications="...Foo"/>
-                    <provides specifications="...Bar">
-                                   <property name="foo" value="baz"/>
-                    </provides>
-    </component>
-
-!ps-foobar2.png!
-
-### Service Property Propagation
-
-The configuration handler has the possibility to propagate received properties to service publication. So, when the propagation is activated (on the `properties` element or on the `@Component` annotation), all properties received by the configuration handler will be propagated to all published services. If some properties are mapped on methods, these methods are invoked with the new value in argument.
-
-!ps-propagation.png!
-
-If an instance configuration contains properties starting with `service.`, they are automatically propagated. In the following example, the `service.pid` is automatically propagated.
-
-    <instance component="...">
-        <property name="service.pid" value="my.pid"/>
-    </instance>
-
-### Instance reconfiguration
-
-iPOJO supports instance reconfiguration. When an instance is dynamically reconfigured and if the instance published service properties, the values are updated with the new configuration. For example, let's take the following component.
-
-{code:java}
+<h2 id="service-properties">Service Properties</h2>
+<p>You can also attach properties to a service registration. Service properties are attached to published service and allow consumer filtering/selecting providers. A property can be attached to a field (contained in the component implementation class), and so can be handle dynamically.</p>
+<p>Let's take a new example very closed of the last one:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">FooProviderType1</span> <span class="n">implements</span> <span class="n">FooService</span> <span class="p">{</span>
+
+    <span class="nv">@ServiceProperty</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;foo&quot;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="s">&quot;Foo&quot;</span><span class="p">)</span>
+    <span class="n">private</span> <span class="n">String</span> <span class="n">m_foo</span><span class="p">;</span>
+
+    <span class="n">public</span> <span class="n">void</span> <span class="n">foo</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;foo  &quot;</span> <span class="o">+</span> <span class="n">m_foo</span><span class="p">);</span>
+        <span class="n">m_foo</span> <span class="o">=</span> <span class="s">&quot;bar&quot;</span><span class="p">;</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>Using XML, it gives:</p>
+<div class="codehilite"><pre><span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;...FooProviderType1&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;foo&quot;</span> <span class="na">field=</span><span class="s">&quot;m_foo&quot;</span> <span class="na">value=</span><span class="s">&quot;Foo&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;/provides&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+</pre></div>
+
+
+<p>The declared property is attached to the <code>m*foo</code> field. This property is published with the name <code>foo</code>. This property has a default value "Foo". This value will be injected into the <code>m*foo</code> field, when this field asks for a value. A property with a field attribute does not need to declare a type (the type can be discovered by analyzing the implementation class).</p>
+<p>The implementation class set a new value to the <code>m_foo</code> field in the code. When this action occurs, the service publication is updated. If a published property value becomes <code>null</code>, the property is unpublished since it has a new value.</p>
+<p>You can also publish 'static' properties (not attached to a field):</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span><span class="p">(</span><span class="n">properties</span><span class="o">=</span> <span class="p">{</span>
+            <span class="nv">@StaticServiceProperty</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;static&quot;</span><span class="p">,</span> <span class="n">type</span><span class="o">=</span><span class="s">&quot;java.lang.String&quot;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="s">&quot;this is a static property&quot;</span><span class="p">)</span>
+    <span class="p">})</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">FooProviderType1</span> <span class="n">implements</span> <span class="n">FooService</span> <span class="p">{</span>
+
+    <span class="nv">@ServiceProperty</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;foo&quot;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="s">&quot;Foo&quot;</span><span class="p">)</span>
+    <span class="n">private</span> <span class="n">String</span> <span class="n">m_foo</span><span class="p">;</span>
+
+    <span class="n">public</span> <span class="n">void</span> <span class="n">foo</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;foo  &quot;</span> <span class="o">+</span> <span class="n">m_foo</span><span class="p">);</span>
+        <span class="n">m_foo</span> <span class="o">=</span> <span class="s">&quot;bar&quot;</span><span class="p">;</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>The second property (<code>Static</code>) is published as a static property. This property is not attached to a field, so, we need to declare the property type. All primitive types or objects can be used has property type (for object, the qualified name of the class is used as java.lang.String).</p>
+<p>In XML, this can also be done:</p>
+<div class="codehilite"><pre><span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;...FooProviderType1&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;foo&quot;</span> <span class="na">field=</span><span class="s">&quot;m_foo&quot;</span> <span class="na">value=</span><span class="s">&quot;Foo&quot;</span><span class="nt">/&gt;</span>
+                        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;static&quot;</span> <span class="na">type=</span><span class="s">&quot;java.lang.String&quot;</span> <span class="na">value=</span><span class="s">&quot;this is a static property&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;/provides&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+</pre></div>
+
+
+<p>Properties may have a default value (set using the <code>value</code> attribute). This value will be used as initial value. The value can be given in the instance configuration. The default value will be overridden in this case:</p>
+<div class="codehilite"><pre><span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;...FooProviderType1&quot;</span><span class="nt">&gt;</span>
+   <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;foo&quot;</span> <span class="na">value=</span><span class="s">&quot;My New Foo Value&quot;</span><span class="nt">/&gt;</span>
+   <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;static&quot;</span> <span class="na">value=</span><span class="s">&quot;My Value For Static&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+</pre></div>
+
+
+<p>Properties can also be 'mandatory'. Mandatories properties must receive a value from the instance configuration. If the instance configuration <em>forgets</em> a mandatory properties, the configuration is rejected. Mandatory attribute let you be sure to receive the complete set of initialization values:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">MyComponent</span> <span class="n">implements</span> <span class="n">MyService</span> <span class="p">{</span>
+
+    <span class="nv">@ServiceProperty</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;username&quot;</span><span class="p">,</span> <span class="n">mandatory</span><span class="o">=</span><span class="n">true</span><span class="p">)</span>
+    <span class="n">private</span> <span class="n">String</span> <span class="n">m_username</span><span class="p">;</span>
+
+    <span class="nv">@Property</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;password&quot;</span><span class="p">,</span> <span class="n">mandatory</span><span class="o">=</span><span class="n">true</span><span class="p">)</span>
+    <span class="n">private</span> <span class="n">String</span> <span class="n">m_password</span><span class="p">;</span>
+
+    <span class="sr">//</span><span class="o">...</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>For the previous components:
+<em> <code>(name=myname, password=****)</code> is a valid configuration
+</em> <code>(password=****)</code> is an invalid configuration that will be rejected by iPOJO</p>
+<h2 id="advanced-features">Advanced features</h2>
+<h3 id="service-serving-object-creation">Service Serving &amp; Object Creation</h3>
+<p>When a consumer requires the published service, the handler sends an object (from the component class) of the implementation class. By default, it is always the same POJO object. If no objects already exists, an instance is created.</p>
+<p>However, the handler supports the OSGi <em>Service Factory</em>. In this case, for each requester bundle, the handler sends a new object. To activate this policy, add the <code>strategy</code> attribute in the <code>provides</code> element:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span><span class="p">(</span><span class="n">strategy</span><span class="o">=</span><span class="s">&quot;SERVICE&quot;</span><span class="p">)</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">MyComponent</span> <span class="n">implements</span> <span class="n">MyService</span> <span class="p">{</span>
+    <span class="sr">//</span><span class="o">...</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>or:</p>
+<div class="codehilite"><pre><span class="o">&lt;</span><span class="n">provides</span> <span class="n">strategy</span><span class="o">=</span><span class="s">&quot;SERVICE&quot;</span><span class="o">/&gt;</span>
+</pre></div>
+
+
+<p>Other strategies are available:
+ * <code>strategy="instance"</code> allows creating one service object per iPOJO instance using the service
+ * it is possible to create your own creation strategy by extending the <code>org.apache.felix.ipojo.handlers.providedservice.CreationStrategy</code> class and by indicating the qualified class name in the <code>strategy</code> attribute:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span><span class="p">(</span><span class="n">strategy</span><span class="o">=</span><span class="s">&quot;org.acme.foo.MyCreationStrategy&quot;</span><span class="p">)</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">MyComponent</span> <span class="n">implements</span> <span class="n">MyService</span> <span class="p">{</span>
+    <span class="sr">//</span><span class="o">...</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<h3 id="providing-several-services-xml-only">Providing Several Services (XML only)</h3>
+<p>In XML, you can declare several <code>provides</code> inside the same component. All those provided services will be managed individually, so will be published using several publication (i.e. <code>org.osgi.frameowrk.ServiceRegistration</code>). This case is useful when service properties are different for the different services.</p>
+<div class="codehilite"><pre><span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;...FooProviderType1&quot;</span><span class="nt">&gt;</span>
+                <span class="nt">&lt;provides</span> <span class="na">specifications=</span><span class="s">&quot;...Foo&quot;</span><span class="nt">/&gt;</span>
+                <span class="nt">&lt;provides</span> <span class="na">specifications=</span><span class="s">&quot;...Bar&quot;</span><span class="nt">&gt;</span>
+                               <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;foo&quot;</span> <span class="na">value=</span><span class="s">&quot;baz&quot;</span><span class="nt">/&gt;</span>
+                <span class="nt">&lt;/provides&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+</pre></div>
+
+
+<p>!ps-foobar2.png!</p>
+<h3 id="service-property-propagation">Service Property Propagation</h3>
+<p>The configuration handler has the possibility to propagate received properties to service publication. So, when the propagation is activated (on the <code>properties</code> element or on the <code>@Component</code> annotation), all properties received by the configuration handler will be propagated to all published services. If some properties are mapped on methods, these methods are invoked with the new value in argument.</p>
+<p>!ps-propagation.png!</p>
+<p>If an instance configuration contains properties starting with <code>service.</code>, they are automatically propagated. In the following example, the <code>service.pid</code> is automatically propagated.</p>
+<div class="codehilite"><pre><span class="nt">&lt;instance</span> <span class="na">component=</span><span class="s">&quot;...&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;service.pid&quot;</span> <span class="na">value=</span><span class="s">&quot;my.pid&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/instance&gt;</span>
+</pre></div>
+
+
+<h3 id="instance-reconfiguration">Instance reconfiguration</h3>
+<p>iPOJO supports instance reconfiguration. When an instance is dynamically reconfigured and if the instance published service properties, the values are updated with the new configuration. For example, let's take the following component.</p>
+<p>{code:java}
 @Component
 @Instantiate
 @Provides
-public class MyComponent implements MyService {
+public class MyComponent implements MyService {</p>
+<div class="codehilite"><pre><span class="nv">@ServiceProperty</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;prop&quot;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="s">&quot;initial&quot;</span><span class="p">)</span>
+<span class="n">private</span> <span class="n">String</span> <span class="n">myProp</span><span class="p">;</span>
 
-    @ServiceProperty(name="prop", value="initial")
-    private String myProp;
+<span class="sr">//</span><span class="o">...</span>
+</pre></div>
 
-    //...
 
-}
+<p>}</p>
+<div class="codehilite"><pre><span class="n">The</span> <span class="n">previous</span> <span class="n">code</span> <span class="n">also</span> <span class="n">declares</span> <span class="n">an</span> <span class="n">instance</span> <span class="p">(</span><span class="n">created</span> <span class="n">without</span> <span class="n">any</span> <span class="n">configuration</span><span class="p">)</span><span class="o">.</span> <span class="n">This</span> <span class="n">instance</span> <span class="n">registers</span>  <span class="n">with</span> <span class="n">the</span> <span class="n">service</span> <span class="n">property</span> <span class="o">=.</span> <span class="n">If</span> <span class="n">this</span> <span class="n">instance</span> <span class="n">is</span> <span class="n">reconfigured</span> <span class="n">using</span> <span class="n">a</span> <span class="n">configuration</span> <span class="n">like:</span> <span class="p">},</span> <span class="n">the</span
 > <span class="n">published</span> <span class="n">properties</span> <span class="n">will</span> <span class="n">be</span> <span class="n">updated</span> <span class="n">with</span> <span class="n">the</span> <span class="k">new</span> <span class="n">value</span><span class="p">,</span> <span class="n">so</span> <span class="o">=.</span>
 
-    The previous code also declares an instance (created without any configuration). This instance registers  with the service property =. If this instance is reconfigured using a configuration like: }, the published properties will be updated with the new value, so =.
+<span class="n">h3</span><span class="o">.</span> <span class="n">Publishing</span> <span class="n">an</span> <span class="n">abstract</span> <span class="ow">or</span> <span class="n">concrete</span> <span class="n">class</span> <span class="n">as</span> <span class="n">a</span> <span class="n">Service</span>
 
-    h3. Publishing an abstract or concrete class as a Service
+<span class="n">It</span> <span class="n">is</span> <span class="n">also</span> <span class="n">possible</span> <span class="n">to</span> <span class="n">expose</span> <span class="n">an</span> <span class="n">abstract</span> <span class="ow">or</span> <span class="n">concrete</span> <span class="n">class</span> <span class="n">as</span> <span class="n">a</span> <span class="n">service</span><span class="o">.</span> <span class="n">To</span> <span class="n">to</span> <span class="n">this</span><span class="p">,</span> <span class="n">just</span> <span class="n">specify</span> <span class="n">the</span> <span class="n">published</span> <span class="n">class</span> <span class="n">in</span> <span class="n">the</span>  <span class="n">attribute:</span>
+</pre></div>
 
-    It is also possible to expose an abstract or concrete class as a service. To to this, just specify the published class in the  attribute:
 
-@Component
+<p>@Component
 @Provides(specifications=MyComponent.class)
 public class MyComponent {
     // ...
-}
-
-    or in XML:
-    {code:xml}
-    <component classname="...FooProviderType1">
-                    <provides specifications="...AbstractFoo"/>
-    </component>
-    <component classname="...FooBarProviderType1">
-                    <provides specifications="[...AbstractFoo, ...Bar]"/>
-    </component>
-
-As illustrated with the example using annotation, the component can also publish itself as a service. However, such practice is not recommended.
-
-### Controlling the service exposition from the implementation class
-
-To control the exposition of the published service, you can use a `service controller`. A service controller is a boolean field of the component class. The injected boolean field allows the code to impact the service publication. Setting the field to `false` unregisters the service from the service registry. Setting it back to `true` re-publishes the service.
-
-{code:java}
+}</p>
+<div class="codehilite"><pre>or in XML:
+{code:xml}
+<span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;...FooProviderType1&quot;</span><span class="nt">&gt;</span>
+                <span class="nt">&lt;provides</span> <span class="na">specifications=</span><span class="s">&quot;...AbstractFoo&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+<span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;...FooBarProviderType1&quot;</span><span class="nt">&gt;</span>
+                <span class="nt">&lt;provides</span> <span class="na">specifications=</span><span class="s">&quot;[...AbstractFoo, ...Bar]&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+</pre></div>
+
+
+<p>As illustrated with the example using annotation, the component can also publish itself as a service. However, such practice is not recommended.</p>
+<h3 id="controlling-the-service-exposition-from-the-implementation-class">Controlling the service exposition from the implementation class</h3>
+<p>To control the exposition of the published service, you can use a <code>service controller</code>. A service controller is a boolean field of the component class. The injected boolean field allows the code to impact the service publication. Setting the field to <code>false</code> unregisters the service from the service registry. Setting it back to <code>true</code> re-publishes the service.</p>
+<p>{code:java}
 @Component
 @Provides
-public class ControllerCheckService implements FooService, CheckService {
-
-    @ServiceController
-    private boolean controller; // Service Controller
+public class ControllerCheckService implements FooService, CheckService {</p>
+<div class="codehilite"><pre><span class="nv">@ServiceController</span>
+<span class="n">private</span> <span class="n">boolean</span> <span class="n">controller</span><span class="p">;</span> <span class="sr">//</span> <span class="n">Service</span> <span class="n">Controller</span>
+
+<span class="n">public</span> <span class="n">boolean</span> <span class="n">foo</span><span class="p">()</span> <span class="p">{</span>
+    <span class="k">return</span> <span class="n">controller</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">boolean</span> <span class="n">check</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;Before : &quot;</span> <span class="o">+</span> <span class="n">controller</span><span class="p">);</span>
+    <span class="n">controller</span> <span class="o">=</span> <span class="o">!</span> <span class="n">controller</span><span class="p">;</span> <span class="sr">//</span> <span class="n">Change</span> <span class="n">the</span> <span class="n">publication</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;After : &quot;</span> <span class="o">+</span> <span class="n">controller</span><span class="p">);</span>
+    <span class="k">return</span> <span class="n">controller</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}</p>
+<div class="codehilite"><pre>Using XML, the previous component description is:
+{code:xml}
+  <span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService&quot;</span>
+    <span class="na">name=</span><span class="s">&quot;PS-Controller-1-default&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;controller&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;/provides&gt;</span>
+  <span class="nt">&lt;/component&gt;</span>
+</pre></div>
+
+
+<p>The <code>controller</code> may have a value attribute setting the initial value. Setting this value to <code>false</code> disables the initial service registration:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">ControllerCheckService</span> <span class="n">implements</span> <span class="n">FooService</span><span class="p">,</span> <span class="n">CheckService</span> <span class="p">{</span>
+
+    <span class="nv">@ServiceController</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="n">false</span><span class="p">)</span>
+    <span class="n">private</span> <span class="n">boolean</span> <span class="n">controller</span><span class="p">;</span> <span class="sr">//</span> <span class="n">Service</span> <span class="n">Controller</span>
+
+    <span class="n">public</span> <span class="n">boolean</span> <span class="n">foo</span><span class="p">()</span> <span class="p">{</span>
+        <span class="k">return</span> <span class="n">controller</span><span class="p">;</span>
+    <span class="p">}</span>
+
+    <span class="n">public</span> <span class="n">boolean</span> <span class="n">check</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;Before : &quot;</span> <span class="o">+</span> <span class="n">controller</span><span class="p">);</span>
+        <span class="n">controller</span> <span class="o">=</span> <span class="o">!</span> <span class="n">controller</span><span class="p">;</span> <span class="sr">//</span> <span class="n">Change</span> <span class="n">the</span> <span class="n">publication</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;After : &quot;</span> <span class="o">+</span> <span class="n">controller</span><span class="p">);</span>
+        <span class="k">return</span> <span class="n">controller</span><span class="p">;</span>
+    <span class="p">}</span>
+
+<span class="p">}</span>
+</pre></div>
+
+
+<p>If several interfaces are exposed, the controller may have a <code>specification</code> attribute indicating the impacted service:</p>
+<div class="codehilite"><pre><span class="nv">@Component</span>
+<span class="nv">@Provides</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">ControllerCheckService</span> <span class="n">implements</span> <span class="n">FooService</span><span class="p">,</span> <span class="n">CheckService</span> <span class="p">{</span>
+
+    <span class="nv">@ServiceController</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="n">false</span><span class="p">,</span> <span class="n">specification</span><span class="o">=</span><span class="n">FooService</span><span class="o">.</span><span class="n">class</span><span class="p">)</span>
+    <span class="n">private</span> <span class="n">boolean</span> <span class="n">controller</span><span class="p">;</span> <span class="sr">//</span> <span class="n">Service</span> <span class="n">Controller</span>
+
+    <span class="n">public</span> <span class="n">boolean</span> <span class="n">foo</span><span class="p">()</span> <span class="p">{</span>
+        <span class="k">return</span> <span class="n">controller</span><span class="p">;</span>
+    <span class="p">}</span>
+
+    <span class="n">public</span> <span class="n">boolean</span> <span class="n">check</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;Before : &quot;</span> <span class="o">+</span> <span class="n">controller</span><span class="p">);</span>
+        <span class="n">controller</span> <span class="o">=</span> <span class="o">!</span> <span class="n">controller</span><span class="p">;</span> <span class="sr">//</span> <span class="n">Change</span> <span class="n">the</span> <span class="n">publication</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;After : &quot;</span> <span class="o">+</span> <span class="n">controller</span><span class="p">);</span>
+        <span class="k">return</span> <span class="n">controller</span><span class="p">;</span>
+    <span class="p">}</span>
+
+<span class="p">}</span>
+</pre></div>
+
+
+<p>In XML, each <code>provides</code> can have one <code>controller</code> element.</p>
+<div class="codehilite"><pre>  <span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService&quot;</span>
+    <span class="na">name=</span><span class="s">&quot;PS-Controller-1-false&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;controller&quot;</span> <span class="na">value=</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>
+</pre></div>
+
+
+<h3 id="being-notified-of-the-service-registration-and-unregistration">Being notified of the service registration and unregistration</h3>
+<p>You can also be notified when the service is published and unpublished. This is done by specifying the two callbacks in the <code>&lt;provides/&gt;</code> element:</p>
+<div class="codehilite"><pre><span class="nt">&lt;component</span>
+     <span class="na">classname=</span><span class="s">&quot;org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService&quot;</span>
+     <span class="na">name=</span><span class="s">&quot;PS-Callbacks-both-1&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;provides</span>
+    <span class="na">specifications=</span><span class="s">&quot;org.apache.felix.ipojo.test.scenarios.ps.service.FooService&quot;</span>
+    <span class="na">post-unregistration=</span><span class="s">&quot;unregistered&quot;</span> <span class="na">post-registration=</span><span class="s">&quot;registered&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;provides</span>
+    <span class="na">specifications=</span><span class="s">&quot;org.apache.felix.ipojo.test.scenarios.ps.service.CheckService&quot;</span>
+    <span class="na">post-unregistration=</span><span class="s">&quot;unregistered&quot;</span> <span class="na">post-registration=</span><span class="s">&quot;registered&quot;</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/component&gt;</span>
+</pre></div>
 
-    public boolean foo() {
-        return controller;
-    }
-
-    public boolean check() {
-        System.out.println("Before : " + controller);
-        controller = ! controller; // Change the publication
-        System.out.println("After : " + controller);
-        return controller;
-    }
-
-}
-
-    Using XML, the previous component description is:
-    {code:xml}
-      <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"
-        name="PS-Controller-1-default">
-        <provides>
-          <controller field="controller"/>
-        </provides>
-      </component>
-
-The `controller` may have a value attribute setting the initial value. Setting this value to `false` disables the initial service registration:
-
-    @Component
-    @Provides
-    public class ControllerCheckService implements FooService, CheckService {
-
-        @ServiceController(value=false)
-        private boolean controller; // Service Controller
-
-        public boolean foo() {
-            return controller;
-        }
-
-        public boolean check() {
-            System.out.println("Before : " + controller);
-            controller = ! controller; // Change the publication
-            System.out.println("After : " + controller);
-            return controller;
-        }
-
-    }
-
-If several interfaces are exposed, the controller may have a `specification` attribute indicating the impacted service:
-
-    @Component
-    @Provides
-    public class ControllerCheckService implements FooService, CheckService {
-
-        @ServiceController(value=false, specification=FooService.class)
-        private boolean controller; // Service Controller
-
-        public boolean foo() {
-            return controller;
-        }
-
-        public boolean check() {
-            System.out.println("Before : " + controller);
-            controller = ! controller; // Change the publication
-            System.out.println("After : " + controller);
-            return controller;
-        }
-
-    }
-
-In XML, each `provides` can have one `controller` element.
-
-      <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"
-        name="PS-Controller-1-false">
-        <provides>
-          <controller field="controller" value="false"/>
-        </provides>
-      </component>
-
-### Being notified of the service registration and unregistration
-You can also be notified when the service is published and unpublished. This is done by specifying the two callbacks in the `<provides/>` element:
-
-    <component
-         classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"
-         name="PS-Callbacks-both-1">
-        <provides
-        specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"
-        post-unregistration="unregistered" post-registration="registered"/>
-        <provides
-        specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"
-        post-unregistration="unregistered" post-registration="registered"/>
-    </component>
 
-Or by using the @PostRegistration and @PostUnregistration annotations:
+<p>Or by using the @PostRegistration and @PostUnregistration annotations:
 {code:java}
     @PostRegistration
     public void registered(ServiceReference ref) {
         System.out.println("Registered");
-    }
-
-        @PostUnregistration
-    public void unregistered(ServiceReference ref) {
-        System.out.println("Unregistered");
-    }
-
-    * The  callback is called after the service publication
-    * The  callback is called after the service unpublication
-
-    Those callback methods must have the following signature: . So they receive the published / unpublished service reference. The callbacks are called in the *same thread* as the publication / unpublication itself. 
+    }</p>
+<div class="codehilite"><pre>    <span class="nv">@PostUnregistration</span>
+<span class="n">public</span> <span class="n">void</span> <span class="n">unregistered</span><span class="p">(</span><span class="n">ServiceReference</span> <span class="nb">ref</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;Unregistered&quot;</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="o">*</span> <span class="n">The</span>  <span class="n">callback</span> <span class="n">is</span> <span class="n">called</span> <span class="n">after</span> <span class="n">the</span> <span class="n">service</span> <span class="n">publication</span>
+<span class="o">*</span> <span class="n">The</span>  <span class="n">callback</span> <span class="n">is</span> <span class="n">called</span> <span class="n">after</span> <span class="n">the</span> <span class="n">service</span> <span class="n">unpublication</span>
+
+<span class="n">Those</span> <span class="n">callback</span> <span class="n">methods</span> <span class="n">must</span> <span class="n">have</span> <span class="n">the</span> <span class="n">following</span> <span class="n">signature:</span> <span class="o">.</span> <span class="n">So</span> <span class="n">they</span> <span class="n">receive</span> <span class="n">the</span> <span class="n">published</span> <span class="sr">/ unpublished service reference. The callbacks are called in the *same thread* as the publication /</span> <span class="n">unpublication</span> <span class="n">itself</span><span class="o">.</span>
+
+<span class="o">\\</span>
+<span class="o">\\</span>
+</pre></div>
+      </div>
+      
+      <img src="http://felix.apache.org/ipojo/site/footer.png" class="footer">
 
-    \\
-    \\
-    {include:apache-felix-ipojo-footer}
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1422427 by fmeschbe on Sun, 16 Dec 2012 00:36:51 +0000
+        Rev. 1441864 by fmeschbe on Sun, 3 Feb 2013 06:44:40 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project
@@ -452,5 +584,18 @@ Or by using the @PostRegistration and @P
         may be trademarks or registered trademarks of their respective owners.
       </div>
     </div>
+    </div>
+    
+    <script type="text/javascript">
+    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+    </script>
+    <script type="text/javascript">
+    try{
+    var pageTracker = _gat._getTracker("UA-1518442-4");
+    pageTracker._trackPageview();
+    } catch(err) {}
+    </script>
+
   </body>
 </html>