felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Felix > iPOJO-Reference-Card
Date Fri, 02 Jul 2010 17:27:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/FELIX/iPOJO-Reference-Card">iPOJO-Reference-Card</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~clement.escoffier">Clement Escoffier</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* [Configuration Handler] <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h1. PostRegistration and PostUnregistration callbacks <br>* This feature is part of the provided service handler, and so requires that the component provides a service. <br>* The callback receives a {{ServiceReference}} as parameter. <br>{code:xml|title=XML} <br>&lt;component <br>     classname=&quot;...&quot;&gt; <br>    &lt;provides <br>	post-unregistration=&quot;unregistered&quot; post-registration=&quot;registered&quot;/&gt; <br>&lt;/component&gt; <br>{code} <br>{code:java|title=Annotations} <br>@PostRegistration <br>public void registered(ServiceReference ref) { <br>	System.out.println(&quot;Registered&quot;); <br>} <br> <br>@PostUnregistration <br>public void unregistered(ServiceReference ref) { <br>	System.out.println(&quot;Unregistered&quot;); <br>} <br>{code} <br>* [Provided Service Handler|http://felix.apache.org/site/providing-osgi-services.html#ProvidingOSGiservices-Beingnotifiedoftheserviceregistrationandunregistration] <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h1. Using &#39;arch&#39; <br>* Deploy the &#39;arch&#39; command bundle (available for Felix and Equinox) <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <style type="text/css">
 @import url(http://felix.apache.org/ipojo/site/superfish.css); 
</style>

<style type="text/css">
 @import url(http://felix.apache.org/ipojo/site/style.css); 
</style>

<p>
<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="http://felix.apache.org/ipojo/site/jquery-1.js"></script>
<script type="text/javascript" src="http://felix.apache.org/ipojo/site/hoverIntent.js"></script>
<script type="text/javascript" src="http://felix.apache.org/ipojo/site/superfish.js"></script> 
<script type="text/javascript" src="http://felix.apache.org/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>
<div class="main">
<div class="page-header"/>
<img src="http://felix.apache.org/ipojo/site/header.png" class="header">
<a href="http://ipojo.org"><img src="http://felix.apache.org/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="/confluence/display/FELIX/Apache+Felix+iPOJO" title="Apache Felix iPOJO">Home</a>							
	</li>
	<li>
	<a href="/confluence/display/FELIX/apache-felix-ipojo-why-choose-ipojo" title="apache-felix-ipojo-why-choose-ipojo">Why choose iPOJO</a>
	</li>
	<li>
	<a href="/confluence/display/FELIX/apache-felix-ipojo-successstories" title="apache-felix-ipojo-successstories">Success stories</a>
	</li>
	<li>
	<a href="/confluence/display/FELIX/Apache+Felix+iPOJO+Feature+Overview" title="Apache Felix iPOJO Feature Overview">Features</a>
	</li>
</ul>
</li>	

<li class="">			
<!-- Menu download -->
<li>
<a href="/confluence/display/FELIX/Download" title="Download">Download </a>
</li>

<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="/confluence/display/FELIX/iPOJO+in+10+minutes" title="iPOJO in 10 minutes">iPOJO in 10 minutes</a></li>
     <li><a href="/confluence/display/FELIX/How+to+use+iPOJO+Annotations" title="How to use iPOJO Annotations">Using Annotations</a></li>
     <li><a href="/confluence/display/FELIX/iPOJO+Hello+Word+%28Maven-Based%29+tutorial" title="iPOJO Hello Word (Maven-Based) tutorial">Maven tutorial</a></li>
     <li><a href="/confluence/display/FELIX/iPOJO+Advanced+Tutorial" title="iPOJO Advanced Tutorial">Advanced tutorial</a></li>
     <li><a href="/confluence/display/FELIX/apache-felix-ipojo-dosgi" title="apache-felix-ipojo-dosgi">Using Distributed OSGi</a></li>
     <li><a href="/confluence/display/FELIX/iPOJO+Composition+Tutorial" title="iPOJO Composition Tutorial">Application Composition</a></li>
    </ul>
    </li> <!-- end of getting started -->
    <!-- sub menu : Describing Components -->
     <li class="">
        <a href="http://felix.apache.org/site/describing-components.html" class="sf-with-ul">Describing components<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a>
        <ul>
        <li><a href="/confluence/display/FELIX/Service+Requirement+Handler" title="Service Requirement Handler">Requiring a service</a></li>
        <li><a href="/confluence/display/FELIX/Providing+OSGi+services" title="Providing OSGi services">Providing a service</a></li>
        <li><a href="/confluence/display/FELIX/Lifecycle+Callback+Handler" title="Lifecycle Callback Handler">Lifecycle management</a></li>
        <li><a href="/confluence/display/FELIX/Configuration+Handler" title="Configuration Handler">Configuration</a></li>
        <li><a href="/confluence/display/FELIX/Architecture+Handler" title="Architecture Handler">Introspection</a></li>
        <li><a href="/confluence/display/FELIX/Controller+Lifecycle+Handler" title="Controller Lifecycle Handler">Impacting the lifecycle</a></li>
        <li><a href="/confluence/display/FELIX/Event+Admin+Handlers" title="Event Admin Handlers">Asynchronous communication</a></li>
        <li><a href="/confluence/display/FELIX/iPOJO+JMX+Handler" title="iPOJO JMX Handler">JMX management</a></li>
        <li><a href="/confluence/display/FELIX/Extender+Pattern+Handler" title="Extender Pattern Handler">Extender pattern</a></li>
        <li><a href="/confluence/display/FELIX/White+Board+Pattern+Handler" title="White Board Pattern Handler">Whiteboard pattern</a></li>
        <li><a href="/confluence/display/FELIX/Temporal+Service+Dependency" title="Temporal Service Dependency">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="/confluence/display/FELIX/Combining+iPOJO+and+Configuration+Admin" title="Combining iPOJO and Configuration Admin">iPOJO and config admin</a></li>
        <li><a href="/confluence/display/FELIX/How-to+use+iPOJO+factories" title="How-to use iPOJO factories">Factories and Instances</a></li>
        <li><a href="/confluence/display/FELIX/Using+XML+Schemas" title="Using XML Schemas">XML Schemas</a></li>
        <li><a href="/confluence/display/FELIX/apache-felix-ipojo-api" title="apache-felix-ipojo-api">API</a></li>
        <li><a href="/confluence/display/FELIX/apache-felix-ipojo-testing-components" title="apache-felix-ipojo-testing-components">Testing components</a></li>
        <li><a href="/confluence/display/FELIX/apache-felix-ipojo-eclipse-integration" title="apache-felix-ipojo-eclipse-integration">Eclipse Integration</a></li>
        <li><a href="/confluence/display/FELIX/iPOJO+FAQ" title="iPOJO FAQ">FAQ</a></li>
        <li><a href="/confluence/display/FELIX/iPOJO-Reference-Card" title="iPOJO-Reference-Card">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" class="external-link" rel="nofollow">Javadoc</a></li>
        <li><a href="/confluence/display/FELIX/How+to+write+your+own+handler" title="How to write your own handler">Handler development</a></li>
        <li><a href="/confluence/display/FELIX/How+to+use+iPOJO+Manipulation+Metadata" title="How to use iPOJO Manipulation Metadata">Manipulation Metadata </a></li>
        <li><a href="/confluence/display/FELIX/Dive+into+the+iPOJO+Manipulation+depths" title="Dive into the iPOJO Manipulation depths">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="/confluence/display/FELIX/iPOJO+Ant+Task" title="iPOJO Ant Task">Ant Task</a></li>
   <li><a href="/confluence/display/FELIX/iPOJO+Eclipse+Plug-in" title="iPOJO Eclipse Plug-in">Eclipse Plugin</a></li>
   <li><a href="/confluence/display/FELIX/iPOJO+Maven+Plug-in" title="iPOJO Maven Plug-in">Maven Plugin</a></li>
   <li><a href="/confluence/display/FELIX/iPOJO-Arch-Command" title="iPOJO-Arch-Command"><tt>arch</tt> shell command</a></li>
   <li><a href="/confluence/display/FELIX/apache-felix-ipojo-online-manipulator" title="apache-felix-ipojo-online-manipulator">Online Manipulator</a></li>
   <li><a href="/confluence/display/FELIX/iPOJO+Webconsole+Plugin" title="iPOJO Webconsole Plugin">Webconsole plugin</a></li>
   <li><a href="/confluence/display/FELIX/apache-felix-ipojo-junit4osgi" title="apache-felix-ipojo-junit4osgi">Junit4OSGi</a></li>
</ul>   
</li><!-- End of tools -->	
<!-- Menu 5 : Support -->
<li>
<a href="/confluence/display/FELIX/ipojo-support" title="ipojo-support">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="/confluence/display/FELIX/apache-felix-ipojo-supportedVMs" title="apache-felix-ipojo-supportedVMs">Supported JVMs</a></li>
   <li><a href="/confluence/display/FELIX/apache-felix-ipojo-supportedOSGi" title="apache-felix-ipojo-supportedOSGi">Supported OSGi Implementations</a></li>
   <li><a href="http://ipojo-dark-side.blogspot.com" class="external-link" rel="nofollow">iPOJO's Dark Side Blog</a></li>
   <li><a href="/confluence/pages/viewpage.action?pageId=54954" title="Article &amp; Presentations">Article &amp; 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 -->
</p>

<div class="content">

<h1><a name="iPOJO-Reference-Card-Declaringcomponenttypes"></a>Declaring component types</h1>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;component
    classname=<span class="code-quote">"my.Implementation"</span>
    name=<span class="code-quote">"my-type"</span>&gt;
<span class="code-tag">&lt;/component&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component(name=<span class="code-quote">"my-type"</span>)
<span class="code-keyword">public</span> class Implementation {
  <span class="code-comment">// ...
</span>}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> classname </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> indicates the implementation class (automatic when using annotations). </td>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> implementation class name </td>
<td class='confluenceTd'> specifies the component type name. </td>
</tr>
<tr>
<td class='confluenceTd'> public <br class="atl-forced-newline" /> (public_factory for annotations) </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> specifies if the component type is accessible from others bundle or is private.</td>
</tr>
<tr>
<td class='confluenceTd'> factory-method <br class="atl-forced-newline" /> (factory_method for annotations) </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies a static method to call instead of the 'regular' constructor to create POJO objects.</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li><a href="/confluence/display/FELIX/How-to+use+iPOJO+factories" title="How-to use iPOJO factories">How&#45;to use iPOJO factories</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-Creatingcomponentinstances"></a>Creating component instances</h1>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;instance component=<span class="code-quote">"my-type"</span>/&gt;</span>
<span class="code-tag">&lt;instance component=<span class="code-quote">"my.Implementation"</span>/&gt;</span>
<span class="code-tag">&lt;instance component=<span class="code-quote">"my-type"</span> name=<span class="code-quote">"my-instance"</span>/&gt;</span>
<span class="code-tag">&lt;instance component=<span class="code-quote">"my-type"</span> name=<span class="code-quote">"my-instance"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"property1"</span> value=<span class="code-quote">"value1"</span>/&gt;</span>
<span class="code-tag">&lt;/instance&gt;</span>
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> component </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the component type (either by using the name or the class name) </td>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> generated </td>
<td class='confluenceTd'> specifies the instance name. </td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li>Instances can contains a configuration given under the <tt>key-value</tt> form. Properties can also by complex type.</li>
	<li><a href="/confluence/display/FELIX/How-to+use+iPOJO+factories" title="How-to use iPOJO factories">How&#45;to use iPOJO factories</a></li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component(name=<span class="code-quote">"my-type"</span>)
@Instantiate
<span class="code-keyword">public</span> class Implementation {
  <span class="code-comment">// ...
</span>}
</pre>
</div></div>

<h1><a name="iPOJO-Reference-Card-Providingservices"></a>Providing services</h1>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;component classname=<span class="code-quote">"my.service.implementation"</span> name=<span class="code-quote">"my-service-impl"</span>&gt;</span>
   <span class="code-tag">&lt;provides/&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>
<span class="code-tag">&lt;instance name=<span class="code-quote">"my-service-impl"</span>/&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
@Provides
<span class="code-keyword">public</span> class Implementation <span class="code-keyword">implements</span> FooService {
   ...
}
</pre>
</div></div>
<ul>
	<li>Only instances provides really services, so don't forget to declare an instance.</li>
	<li>Published service interfaces must be implemented by your component implementation
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> specifications </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> all implemented interfaces </td>
<td class='confluenceTd'> specifies the published service interfaces </td>
</tr>
<tr>
<td class='confluenceTd'> strategy </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> <tt>singleton</tt> </td>
<td class='confluenceTd'> specifies the service object creation policy among <tt>singleton</tt>, <tt>service</tt> (OSGi Service Factory), <tt>method</tt> (use the factory method), <tt>instance</tt> (an object per instance) </td>
</tr>
</tbody></table>
</div>
</div>
</div></li>
	<li><a href="/confluence/display/FELIX/Providing+OSGi+services" title="Providing OSGi services">Providing OSGi services</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-Publishingserviceproperties"></a>Publishing service properties</h1>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;component classname=<span class="code-quote">"my.service.implementation"</span> name=<span class="code-quote">"my-service-impl"</span>&gt;</span>
  <span class="code-tag">&lt;provides&gt;</span>
	<span class="code-tag">&lt;property name=<span class="code-quote">"foo"</span> field=<span class="code-quote">"m_foo"</span> /&gt;</span>
	<span class="code-tag">&lt;property name=<span class="code-quote">"bar"</span> field=<span class="code-quote">"m_bar"</span> mandatory=<span class="code-quote">"true"</span> /&gt;</span>
	<span class="code-tag">&lt;property name=<span class="code-quote">"baz"</span> type=<span class="code-quote">"java.lang.String"</span> /&gt;</span> <span class="code-tag"><span class="code-comment">&lt;!-- Static property (do not change at runtime) --&gt;</span></span>
  <span class="code-tag">&lt;/provides&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>
<span class="code-tag">&lt;instance name=<span class="code-quote">"my-service-impl"</span>&gt;</span> <span class="code-tag"><span class="code-comment">&lt;!-- The configuration has to inject value in unvalued mandatory properties --&gt;</span></span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"bar"</span> value=<span class="code-quote">"5"</span>/&gt;</span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"baz"</span> value=<span class="code-quote">"my string"</span>/&gt;</span>
<span class="code-tag">&lt;instance/&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
@Provides(specifications= {FooService.class, BarService.class})
<span class="code-keyword">public</span> class ProvidesProperties <span class="code-keyword">implements</span> FooService, BarService {
    
    @ServiceProperty(name = <span class="code-quote">"foo"</span>)
    <span class="code-keyword">public</span> <span class="code-object">int</span> m_foo = 0;
    
    @ServiceProperty(name=<span class="code-quote">"bar"</span>, mandatory=<span class="code-keyword">true</span>)
    <span class="code-keyword">public</span> <span class="code-object">int</span> m_bar;
    
<span class="code-comment">// ...
</span>}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> field name </td>
<td class='confluenceTd'> specifies the published property name </td>
</tr>
<tr>
<td class='confluenceTd'> mandatory </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> specifies if the property has to receive a value from the instance configuration </td>
</tr>
<tr>
<td class='confluenceTd'> value </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the default property value </td>
</tr>
<tr>
<td class='confluenceTd'> field </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> (automatic with annotations) </td>
<td class='confluenceTd'> specifies the field attached to the service property </td>
</tr>
<tr>
<td class='confluenceTd'> type </td>
<td class='confluenceTd'> Only if there is no field information (generated) </td>
<td class='confluenceTd'> Type of the property </td>
</tr>
</tbody></table>
</div>

</div>
</div>
<ul>
	<li><a href="/confluence/display/FELIX/Providing+OSGi+services" title="Providing OSGi services">Providing OSGi services</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-Usingserviceswithfieldinjection"></a>Using services with field injection</h1>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;component classname=<span class="code-quote">"my.consumer.Implementation"</span>&gt;</span>
    <span class="code-tag">&lt;requires field=<span class="code-quote">"fs"</span> /&gt;</span>
    <span class="code-tag">&lt;requires field=<span class="code-quote">"bs"</span> /&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
<span class="code-keyword">public</span> class Dependency {

    @Requires
    <span class="code-keyword">public</span> FooService fs;

    @Requires
    <span class="code-keyword">public</span> BarService[] bs;
    
    <span class="code-comment">//...
</span>}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> id </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> field name </td>
<td class='confluenceTd'> dependency id </td>
</tr>
<tr>
<td class='confluenceTd'> field </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> automatically detected with annotations </td>
<td class='confluenceTd'> injected field </td>
</tr>
<tr>
<td class='confluenceTd'> optional </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> specifies if the dependency if optional </td>
</tr>
<tr>
<td class='confluenceTd'> aggregate </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false <br class="atl-forced-newline" /> (automatically detected with fields) </td>
<td class='confluenceTd'> specifies if the dependency is aggregate of <tt>scalar</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> specification </td>
<td class='confluenceTd'> yes/no </td>
<td class='confluenceTd'> can be discovered from the code </td>
<td class='confluenceTd'> specifies the required service specification. This attribute is required when the service type cannot be inferred from the code (Collection type for fields, callbacks without service objects) </td>
</tr>
<tr>
<td class='confluenceTd'> filter </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> no filter </td>
<td class='confluenceTd'> specifies the dependency LDAP filter </td>
</tr>
<tr>
<td class='confluenceTd'> from </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies a specific provider by its name </td>
</tr>
<tr>
<td class='confluenceTd'> policy </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> <tt>dynamic</tt> </td>
<td class='confluenceTd'> specifies the binding policy among <tt>dynamic</tt>, <tt>static</tt> and <tt>dynamic-priority</tt>  </td>
</tr>
<tr>
<td class='confluenceTd'> nullable </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> enables/disables nullable object injection for optional dependencies  </td>
</tr>
<tr>
<td class='confluenceTd'> default-implementation // defaultimplementation for annotations </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the default-implementation for optional dependencies  </td>
</tr>
<tr>
<td class='confluenceTd'> comparator </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the comparator class used to sort service providers </td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li><a href="/confluence/display/FELIX/Service+Requirement+Handler" title="Service Requirement Handler">Service Requirement Handler</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-Usingserviceswithmethodinjection"></a>Using services with method injection</h1>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;component classname=<span class="code-quote">"my.consumer.Implementation"</span>&gt;</span>
    <span class="code-tag">&lt;requires&gt;</span>
	<span class="code-tag">&lt;callback type=<span class="code-quote">"bind"</span> method=<span class="code-quote">"bind"</span> /&gt;</span>
	<span class="code-tag">&lt;callback type=<span class="code-quote">"unbind"</span> method=<span class="code-quote">"unbind"</span> /&gt;</span>
    <span class="code-tag">&lt;/requires&gt;</span>	
<span class="code-tag">&lt;/component&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
<span class="code-keyword">public</span> class Dependency {

    @Unbind
    <span class="code-keyword">public</span> <span class="code-keyword">synchronized</span> void unbind(BazService bz) {
        <span class="code-comment">//...
</span>    }
    
    @Bind
    <span class="code-keyword">public</span> <span class="code-keyword">synchronized</span> void bind(BazService bz) {
        <span class="code-comment">// ...
</span>    }

  <span class="code-comment">//...
</span>}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> id </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> field name </td>
<td class='confluenceTd'> dependency id </td>
</tr>
<tr>
<td class='confluenceTd'> field </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> automatically detected with annotations </td>
<td class='confluenceTd'> injected field </td>
</tr>
<tr>
<td class='confluenceTd'> optional </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> specifies if the dependency if optional </td>
</tr>
<tr>
<td class='confluenceTd'> aggregate </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false <br class="atl-forced-newline" /> (automatically detected with fields) </td>
<td class='confluenceTd'> specifies if the dependnency is aggregate of <tt>scalar</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> specification </td>
<td class='confluenceTd'> yes/no </td>
<td class='confluenceTd'> can be discovered from the code </td>
<td class='confluenceTd'> specifies the required service specification. This attribute is required when the service type cannot be infered from the code (Collection type for fields, callbacks without service objects) </td>
</tr>
<tr>
<td class='confluenceTd'> filter </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> no filter </td>
<td class='confluenceTd'> specifies the dependency LDAP filter </td>
</tr>
<tr>
<td class='confluenceTd'> from </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies a specific provider by its name </td>
</tr>
<tr>
<td class='confluenceTd'> policy </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> <tt>dynamic</tt> </td>
<td class='confluenceTd'> specifies the binding policy among <tt>dynamic</tt>, <tt>static</tt> and <tt>dynamic-priority</tt>  </td>
</tr>
<tr>
<td class='confluenceTd'> nullable </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> enables/disables nullable object injection for optional dependencies  </td>
</tr>
<tr>
<td class='confluenceTd'> default-implementation // default implementation for annotations </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the default-implementation for optional dependencies  </td>
</tr>
<tr>
<td class='confluenceTd'> comparator </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the comparator class used to sort service providers </td>
</tr>
</tbody></table>
</div>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Sub-Element name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> callback </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> callback specifies bind and unbind method. Two attributes are required (discovered automatically with annotations). <tt>type</tt> specified if the callback is a bind or unbind method (among {<tt>bind</tt>, <tt>unbind</tt>}. The <tt>method</tt> attribute specified the method to call.</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li><a href="/confluence/display/FELIX/Service+Requirement+Handler" title="Service Requirement Handler">Service Requirement Handler</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-Configuringservicedependenciesintheinstanceconfiguration"></a>Configuring service dependencies in the instance configuration</h1>
<h2><a name="iPOJO-Reference-Card-Configuringthe%7B%7Bfrom%7D%7Dattribute"></a>Configuring the <tt>from</tt> attribute</h2>
<ul>
	<li>Thanks to the <tt>requires.from</tt> property, it is possible to override the <tt>from</tt> attribute value.</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;component 
   classname=<span class="code-quote">"...MyComponent"</span>
   name=<span class="code-quote">"FOO"</span>&gt;
	<span class="code-tag">&lt;requires field=<span class="code-quote">"m_foo"</span> id=<span class="code-quote">"id1"</span>&gt;</span>
		<span class="code-tag">&lt;callback type=<span class="code-quote">"bind"</span> method=<span class="code-quote">"bind"</span>/&gt;</span>
		<span class="code-tag">&lt;callback type=<span class="code-quote">"unbind"</span> method=<span class="code-quote">"unbind"</span>/&gt;</span>
	<span class="code-tag">&lt;/requires&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>

<span class="code-tag">&lt;instance name=<span class="code-quote">"FOO1"</span> component=<span class="code-quote">"FOO"</span>/&gt;</span> <span class="code-tag"><span class="code-comment">&lt;!-- Use the default 'from' value --&gt;</span></span>

<span class="code-tag">&lt;instance name=<span class="code-quote">"FOO2"</span> component=<span class="code-quote">"FOO"</span>&gt;</span>
	<span class="code-tag">&lt;property name=<span class="code-quote">"requires.from"</span>&gt;</span>
		<span class="code-tag">&lt;property name=<span class="code-quote">"id1"</span> value=<span class="code-quote">"myprovider"</span>/&gt;</span>
	<span class="code-tag">&lt;/property&gt;</span>
<span class="code-tag">&lt;/instance&gt;</span>
</pre>
</div></div>
<h2><a name="iPOJO-Reference-Card-Configuringthe%7B%7Bfilter%7D%7Dattribute"></a>Configuring the <tt>filter</tt> attribute</h2>
<ul>
	<li>Thanks to the <tt>requires.filters</tt> property, it is possible to override the <tt>filter</tt> attribute value.</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;component 
   classname=<span class="code-quote">"org.apache.felix.ipojo.example.FilteredDependency"</span> 
   name=<span class="code-quote">"FOO"</span>&gt;
	<span class="code-tag">&lt;requires field=<span class="code-quote">"m_foo"</span> fiter=<span class="code-quote">"(foo.property=FOO)"</span> id=<span class="code-quote">"id1"</span>&gt;</span>
		<span class="code-tag">&lt;callback type=<span class="code-quote">"bind"</span> method=<span class="code-quote">"bind"</span>/&gt;</span>
		<span class="code-tag">&lt;callback type=<span class="code-quote">"unbind"</span> method=<span class="code-quote">"unbind"</span>/&gt;</span>
	<span class="code-tag">&lt;/requires&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>

<span class="code-tag">&lt;instance name=<span class="code-quote">"FOO1"</span> component=<span class="code-quote">"FOO"</span>/&gt;</span> <span class="code-tag"><span class="code-comment">&lt;!-- Use the default 'filter' value --&gt;</span></span>

<span class="code-tag">&lt;instance name=<span class="code-quote">"FOO2"</span> component=<span class="code-quote">"FOO"</span>&gt;</span>
	<span class="code-tag">&lt;property name=<span class="code-quote">"requires.filters"</span>&gt;</span>
		<span class="code-tag">&lt;property name=<span class="code-quote">"id1"</span> value=<span class="code-quote">"(foo.property=BAR)"</span>/&gt;</span>
	<span class="code-tag">&lt;/property&gt;</span>
<span class="code-tag">&lt;/instance&gt;</span>
</pre>
</div></div>

<h1><a name="iPOJO-Reference-Card-Reactingtolifecyclestatechanges"></a>Reacting to lifecycle state changes</h1>
<h2><a name="iPOJO-Reference-Card-Immediatecomponents"></a>Immediate components</h2>
<ul>
	<li>A POJO object (implementation object) is created as soons as the instance becomes valid</li>
	<li>Instances that don't provide services becomes automatically immediate
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;component classname=<span class="code-quote">"my.service.implementation"</span> name=<span class="code-quote">"my-service-impl"</span> immediate=<span class="code-quote">"true"</span>&gt;</span>
   <span class="code-tag">&lt;provides/&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component(immediate=<span class="code-keyword">true</span>)
@Provides
<span class="code-keyword">public</span> class Implementation <span class="code-keyword">implements</span> FooService {
   ...
}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> immediate </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false // true for instances that don't provide a service </td>
<td class='confluenceTd'> specifies if the instance is immediate or not </td>
</tr>
</tbody></table>
</div>
</div>
</div></li>
	<li><a href="/confluence/display/FELIX/Lifecycle+Callback+Handler" title="Lifecycle Callback Handler">Lifecycle Callback Handler</a></li>
</ul>


<h2><a name="iPOJO-Reference-Card-Lifecyclecallbacks"></a>Lifecycle callbacks</h2>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;component classname=<span class="code-quote">"my.implementation"</span> name=<span class="code-quote">"my-impl"</span>&gt;</span>
    <span class="code-tag">&lt;callback transition=<span class="code-quote">"validate"</span> method=<span class="code-quote">"start"</span> /&gt;</span>
    <span class="code-tag">&lt;callback transition=<span class="code-quote">"invalidate"</span> method=<span class="code-quote">"stop"</span> /&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
<span class="code-keyword">public</span> class Implementation {
    
    @Validate
    <span class="code-keyword">public</span> void start() {
        
    }
    
    @Invalidate
    <span class="code-keyword">public</span> void stop() {
        
    }
}
</pre>
</div></div>
<ul>
	<li><a href="/confluence/display/FELIX/Lifecycle+Callback+Handler" title="Lifecycle Callback Handler">Lifecycle Callback Handler</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-Declaringproperties"></a>Declaring properties</h1>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;component classname=<span class="code-quote">"my.Implementation"</span> name=<span class="code-quote">"my-impl"</span>&gt;</span>
    <span class="code-tag">&lt;properties propagation=<span class="code-quote">"true"</span> managedservice=<span class="code-quote">"MyPID"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"boo"</span> method=<span class="code-quote">"setBoo"</span> /&gt;</span>
	<span class="code-tag">&lt;property field=<span class="code-quote">"m_bar"</span> mandatory=<span class="code-quote">"true"</span>/&gt;</span>
	<span class="code-tag">&lt;property field=<span class="code-quote">"m_foo"</span> value=<span class="code-quote">"4"</span>/&gt;</span>
    <span class="code-tag">&lt;/properties&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>
<span class="code-tag">&lt;instance component=<span class="code-quote">"my-impl"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"boo"</span> value=<span class="code-quote">"..."</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"m_bar"</span> value=<span class="code-quote">"..."</span>/&gt;</span>
<span class="code-tag">&lt;/instance&gt;</span>
<span class="code-tag">&lt;instance component=<span class="code-quote">"my-impl"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"boo"</span> value=<span class="code-quote">"..."</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"m_bar"</span> value=<span class="code-quote">"..."</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"managed.service.pid"</span> value=<span class="code-quote">"AnotherPID"</span>/&gt;</span>
<span class="code-tag">&lt;/instance&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component(managedservice=<span class="code-quote">"MyPID"</span>, propagation=<span class="code-keyword">true</span>)
<span class="code-keyword">public</span> class Implementation {
    
    @Property(name=<span class="code-quote">"boo"</span>)
    <span class="code-keyword">public</span> void setBoo(<span class="code-object">int</span> boo) {
        <span class="code-comment">//...
</span>    }
        
    @Property(mandatory=<span class="code-keyword">true</span>)
    <span class="code-keyword">public</span> <span class="code-object">int</span> m_bar;

    @Property(value=<span class="code-quote">"4"</span>)
    <span class="code-keyword">public</span> <span class="code-object">int</span> m_foo;
}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> propagation </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> specifies if the properties propagation (properties are also published as service properties) is enabled or disabled </td>
</tr>
<tr>
<td class='confluenceTd'> managedservice </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> instance name </td>
<td class='confluenceTd'> specifies the PID of the published managed service. // This value can be overidden by the <tt>managed.service.pid</tt> instance property </td>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> field name or computed from the method name </td>
<td class='confluenceTd'> specifies if the the property name </td>
</tr>
<tr>
<td class='confluenceTd'> value </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the default property value </td>
</tr>
<tr>
<td class='confluenceTd'> field </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> automatically detected with annotations </td>
<td class='confluenceTd'> specifies the field in which the property value will be injected </td>
</tr>
<tr>
<td class='confluenceTd'> method </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> automatically detected with annotations </td>
<td class='confluenceTd'> specifies the setter method in which the property value will be injected </td>
</tr>
<tr>
<td class='confluenceTd'> mandatory </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> specifies if the property has to receive a value from the instance configuration </td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li><a href="/confluence/display/FELIX/Configuration+Handler" title="Configuration Handler">Configuration Handler</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-PostRegistrationandPostUnregistrationcallbacks"></a>PostRegistration and PostUnregistration callbacks</h1>
<ul>
	<li>This feature is part of the provided service handler, and so requires that the component provides a service.</li>
	<li>The callback receives a <tt>ServiceReference</tt> as parameter.
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;component
     classname=<span class="code-quote">"..."</span>&gt;
    &lt;provides
	post-unregistration=<span class="code-quote">"unregistered"</span> post-registration=<span class="code-quote">"registered"</span>/&gt;
<span class="code-tag">&lt;/component&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@PostRegistration
<span class="code-keyword">public</span> void registered(ServiceReference ref) {
	<span class="code-object">System</span>.out.println(<span class="code-quote">"Registered"</span>);
}

@PostUnregistration
<span class="code-keyword">public</span> void unregistered(ServiceReference ref) {
	<span class="code-object">System</span>.out.println(<span class="code-quote">"Unregistered"</span>);
}
</pre>
</div></div></li>
	<li><a href="http://felix.apache.org/site/providing-osgi-services.html#ProvidingOSGiservices-Beingnotifiedoftheserviceregistrationandunregistration" class="external-link" rel="nofollow">Provided Service Handler</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-Using%27arch%27"></a>Using 'arch'</h1>
<ul>
	<li>Deploy the 'arch' command bundle (available for Felix and Equinox)</li>
	<li>Launch the 'arch' command in the OSGi Framework Shell
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
arch =&gt; displays instances name &amp; state (equivalent to arch \-instances)
arch -instance $instance_name =&gt; displays complete information about the instance $instance_name
arch -factories =&gt; display the list of available factories
arch -factory $factory_name =&gt; display complete information about the factory $factory_name
arch -handlers =&gt; list available handlers
</pre>
</div></div></li>
	<li><a href="/confluence/display/FELIX/iPOJO-Arch-Command" title="iPOJO-Arch-Command">iPOJO Arch Command</a></li>
	<li><a href="/confluence/display/FELIX/Architecture+Handler" title="Architecture Handler">Architecture Handler</a></li>
</ul>


<h1><a name="iPOJO-Reference-Card-TemporalDependencies"></a>Temporal Dependencies</h1>
<ul>
	<li>Temporal dependencies are injected in fields. When accessing to the service, the thread waits for the service availability. If a timeout is reached, a timeout policy is executed.</li>
	<li>Service objects can be injected as <tt>proxies</tt> and be given to collaborator objects.</li>
	<li>Temporal dependencies are implemented as an <em>external handlers</em>. To use them, deploy and start the temporal dependency handler bundle.</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;iPOJO <span class="code-keyword">xmlns:temporal</span>=<span class="code-quote">"org.apache.felix.ipojo.handler.temporal"</span>&gt;</span>
&lt;component
    className=<span class="code-quote">"my.Implementation"</span>&gt;

    <span class="code-tag"><span class="code-comment">&lt;!-- Temporal dependency configuration --&gt;</span></span>
    <span class="code-tag">&lt;temporal:requires field=<span class="code-quote">"mytemporal"</span>/&gt;</span>
    <span class="code-tag">&lt;provides/&gt;</span>
<span class="code-tag">&lt;/component&gt;</span>
<span class="code-tag">&lt;/iPOJO&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">import</span> org.apache.felix.ipojo.annotations.Component;
<span class="code-keyword">import</span> org.apache.felix.ipojo.handler.temporal.Requires;
<span class="code-keyword">import</span> org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;

@Component
<span class="code-keyword">public</span> class Implementation {
    
    @Requires <span class="code-comment">// org.apache.felix.ipojo.handler.temporal.Requires
</span>    <span class="code-keyword">private</span> FooService mytemporal;
    
}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> field </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> automatically detected with annotations </td>
<td class='confluenceTd'> specifies the field in which the service object will be injected </td>
</tr>
<tr>
<td class='confluenceTd'> timeout </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> 3000 ms </td>
<td class='confluenceTd'> specifies the timeout value (in ms). When the timeout is reached, the on timeout policy is executed </td>
</tr>
<tr>
<td class='confluenceTd'> onTimeout </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> Runtime Exception </td>
<td class='confluenceTd'> specifies the on timeout policy. Possible values are: <tt>null</tt>, <tt>nullable</tt>, <tt>empty</tt>, <em>default-implementation</em> (class name) </td>
</tr>
<tr>
<td class='confluenceTd'> specification </td>
<td class='confluenceTd'> only when using Collections </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the required service specification. This attribute is required when the injected field is a Collection </td>
</tr>
<tr>
<td class='confluenceTd'> proxy </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> enables/disables proxy injection. Service injected as proxies can be given to collaborators </td>
</tr>
<tr>
<td class='confluenceTd'> filter </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>  no filter </td>
<td class='confluenceTd'> Filter use to discover matching filter. </td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li><a href="/confluence/display/FELIX/Temporal+Service+Dependency" title="Temporal Service Dependency">Temporal Service Dependency</a></li>
</ul>



<h1><a name="iPOJO-Reference-Card-Sendingandreceivingevents"></a>Sending and receiving events</h1>

<h2><a name="iPOJO-Reference-Card-Receivingevents"></a>Receiving events</h2>

<ul>
	<li>The event admin handler allows receiving events from the Event Admin.</li>
	<li>The event admin handler is implemented as an <em>external handlers</em>. To use it, deploy and start the event admin handler bundle and an implementation of the event admin service.</li>
	<li>Event (or data) are receive thanks to a callback method.</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;ipojo
    <span class="code-keyword">xmlns:ev</span>=<span class="code-quote">"org.apache.felix.ipojo.handlers.event.EventAdminHandler"</span>&gt;
	<span class="code-tag">&lt;component className=<span class="code-quote">"...MyComponent"</span>&gt;</span>
		&lt;ev:subscriber
			name=<span class="code-quote">"mySubscriber"</span>
			callback=<span class="code-quote">"receive"</span>
			topics=<span class="code-quote">"foo"</span>/&gt;
	<span class="code-tag">&lt;/component&gt;</span>
<span class="code-tag">&lt;/ipojo&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
<span class="code-keyword">public</span> class MyComponent {
    
    @Subscriber(name=<span class="code-quote">"s1"</span>, data_key=<span class="code-quote">"data"</span>)
    <span class="code-keyword">public</span> void receive1(<span class="code-object">Object</span> foo) {
        <span class="code-comment">// Nothing
</span>    }
    
    @Subscriber(name=<span class="code-quote">"s2"</span>, topics=<span class="code-quote">"foo,bar"</span>, filter=<span class="code-quote">"(foo=<span class="code-keyword">true</span>)"</span>)
    <span class="code-keyword">public</span> void receive2(Event foo) {
        <span class="code-comment">// Nothing
</span>    }
    
    
    @Subscriber(name=<span class="code-quote">"s3"</span>, topics=<span class="code-quote">"foo"</span>, data_key=<span class="code-quote">"data"</span>, data_type=<span class="code-quote">"java.lang.<span class="code-object">String</span>"</span>)
    <span class="code-keyword">public</span> void receive3(<span class="code-object">String</span> foo) {
        <span class="code-comment">// Nothing
</span>    }
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the name of the event subscriber, acting as a unique identifier. This name is used to configure event subscription in the instance configuration. </td>
</tr>
<tr>
<td class='confluenceTd'> callback (or method) </td>
<td class='confluenceTd'> yes <br class="atl-forced-newline" /> automatically detected with annotations </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies The name of the method called each time an event is received. This method takes only one parameter, of type <tt>org.osgi.service.event.Event</tt> by default, but this type can be overridden by defining the <tt>data-key</tt> and/or the <tt>data-type</tt> attributes. </td>
</tr>
<tr>
<td class='confluenceTd'> topics </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the list (comma-separated-list) of the topics that the handler will listen to. Each event sent on a topic present in this list will be sent to the specified callback method. This parameter can be overridden by instances </td>
</tr>
<tr>
<td class='confluenceTd'> data-key <br class="atl-forced-newline" /> data_key when using annotations </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the data key used when you want to receive data events. This attribute's value is the key corresponding to the received data in the event's dictionary.<br/>
If you use this attribute, the parameter passed to the callback method is the the value associated to this key, not the whole event. This attribute is generally used with the <tt>data-type</tt> attribute to specify the received object type. If an event is received and it does not contain such a key, it is ignored (with a warning message).  </td>
</tr>
<tr>
<td class='confluenceTd'> data-type <br class="atl-forced-newline" /> data_type when using annotations </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> java.lang.Object </td>
<td class='confluenceTd'> specifies the type of objects (<tt>java.lang.Object</tt> by default) that the callback expects. It is used to determine the unique callback method (in case of multiple methods with the same name) and to check type compliance at event reception. Data events that are not corresponding to the specified type will be ignored (with a warning message).</td>
</tr>
<tr>
<td class='confluenceTd'> filter </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> no filter </td>
<td class='confluenceTd'> specifies the event LDAP filter used to filter incoming events before sending them to the callback. The syntax of this field is described in the OSGi EventAdmin Specification. If you don't specify a filter, all events sent on the listened topics will be considered.   </td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li>Instance configuration
	<ul>
		<li>event.topics : overrides <tt>topics</tt> attribute</li>
		<li>event.filter : overrides <tt>filter</tt> attribute</li>
	</ul>
	</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Instance configuration</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;instance component=<span class="code-quote">"...MyComponent"</span>&gt;</span>
		<span class="code-tag">&lt;property name=<span class="code-quote">"event.topics"</span>&gt;</span>
			<span class="code-tag">&lt;property name=<span class="code-quote">"mySubscriber"</span> value=<span class="code-quote">"foo"</span>/&gt;</span>
		<span class="code-tag">&lt;/property&gt;</span>
		<span class="code-tag">&lt;property name=<span class="code-quote">"event.filter"</span>&gt;</span>
			&lt;property name=<span class="code-quote">"mySubscriber"</span>
				    value=<span class="code-quote">"|((arg=Minibar)(arg=Coconuts))"</span>/&gt;
		<span class="code-tag">&lt;/property&gt;</span>
	<span class="code-tag">&lt;/instance&gt;</span>
</pre>
</div></div>

<ul>
	<li><a href="/confluence/display/FELIX/Event+Admin+Handlers" title="Event Admin Handlers">Event Admin Handlers</a></li>
</ul>


<h2><a name="iPOJO-Reference-Card-Sendingevents"></a>Sending events</h2>

<ul>
	<li>The event admin handler allows sending events to the Event Admin.</li>
	<li>The event admin handler is implemented as an <em>external handlers</em>. To use it, deploy and start the event admin handler bundle and an implementation of the event admin service.</li>
	<li>To send events, your code must contains a <tt>org.apache.felix.ipojo.handlers.event.publisher.Publisher</tt> field.</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;ipojo
    <span class="code-keyword">xmlns:ev</span>=<span class="code-quote">"org.apache.felix.ipojo.handlers.event.EventAdminHandler"</span>&gt;
	<span class="code-tag">&lt;component className=<span class="code-quote">"...MyComponent"</span>&gt;</span>
		&lt;ev:publisher
			name=<span class="code-quote">"myPublisher"</span>
			field=<span class="code-quote">"m_publisher"</span>
			topics=<span class="code-quote">"bar,nuts"</span>/&gt;
	<span class="code-tag">&lt;/component&gt;</span>
	<span class="code-tag">&lt;instance component=<span class="code-quote">"...MyComponent"</span>/&gt;</span>
<span class="code-tag">&lt;/ipojo&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">

@Component
<span class="code-keyword">public</span> class MyComponent {
    <span class="code-comment">// We use qualified names to avoid conflict.
</span>    @org.apache.felix.ipojo.handlers.event.Publisher(name=<span class="code-quote">"p1"</span>, synchronous=<span class="code-keyword">true</span>)
    org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher1;
    
    @org.apache.felix.ipojo.handlers.event.Publisher(name=<span class="code-quote">"p2"</span>, synchronous=<span class="code-keyword">false</span>, topics=<span class="code-quote">"foo,bar"</span>, data_key=<span class="code-quote">"data"</span>)
    org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher2;
    
    @org.apache.felix.ipojo.handlers.event.Publisher(name=<span class="code-quote">"p3"</span>, synchronous=<span class="code-keyword">true</span>, topics=<span class="code-quote">"bar"</span>)
    org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher3;

    <span class="code-comment">// ...
</span>
    <span class="code-keyword">public</span> void doSomething() {
        Dictionary e = <span class="code-keyword">new</span> Properties();
        <span class="code-comment">//...
</span>        <span class="code-comment">// Fill out the event
</span>
        <span class="code-comment">// Send event
</span>        publisher1.send(e);
    }
}
</pre>
</div></div>

<ul>
	<li><a href="/confluence/display/FELIX/Event+Admin+Handlers" title="Event Admin Handlers">Event Admin Handlers</a></li>
</ul>


<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the name of the event publisher, acting as a unique identifier. This name is used to configure event publishing in the instance configuration. </td>
</tr>
<tr>
<td class='confluenceTd'> field </td>
<td class='confluenceTd'> yes <br class="atl-forced-newline" /> automatically detected with annotations </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies The name of the field used to send events. The field is initialized at component instantiation time. The type of the field must be : <tt>org.apache.felix.ipojo.handlers.event.publisher.Publisher</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> topics </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the list (comma-separated-list) of the topics on which events will be sent. This parameter can be overridden by instances </td>
</tr>
<tr>
<td class='confluenceTd'> data-key <br class="atl-forced-newline" /> data_key when using annotations </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> user.data </td>
<td class='confluenceTd'> specifies the data key used when you want to send data events.  This attribute's value is the key, in the event's dictionary, in which sent data are stored. When you use the <em>sendData</em> method of the Publisher, the given object is placed in the event dictionary, associated with the specified data-key.  </td>
</tr>
<tr>
<td class='confluenceTd'> synchronous </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> specifies if event sending is synchronous or not.   </td>
</tr>
</tbody></table>
</div>
</div>
</div>

<ul>
	<li>Instance configuration
	<ul>
		<li>event.topics : overrides <tt>topics</tt> attribute</li>
	</ul>
	</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Instance configuration</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;instance component=<span class="code-quote">"...MyComponent"</span>&gt;</span>
		<span class="code-tag">&lt;property name=<span class="code-quote">"event.topics"</span>&gt;</span>
			<span class="code-tag">&lt;property name=<span class="code-quote">"myPublisher"</span> value=<span class="code-quote">"foo"</span>/&gt;</span>
		<span class="code-tag">&lt;/property&gt;</span>
	<span class="code-tag">&lt;/instance&gt;</span>
</pre>
</div></div>

<h1><a name="iPOJO-Reference-Card-ExtenderPattern"></a>Extender Pattern</h1>
<ul>
	<li>Allows implementing an <tt>Extender pattern</tt> without handling obscure details</li>
	<li>The extender pattern handler is implemented as an <em>external handlers</em>. To use it, deploy and start the external pattern handler bundle.</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;ipojo <span class="code-keyword">xmlns:extender</span>=<span class="code-quote">"org.apache.felix.ipojo.extender"</span>&gt;</span>
	&lt;component
		classname=<span class="code-quote">"org.apache.felix.ipojo.extender.Myextender"</span>&gt;
		
                <span class="code-tag">&lt;!—Extender Pattern handler configuration --&gt;</span>
		&lt;extender:extender 
                  extension=<span class="code-quote">"My-Extension"</span>
                  onArrival=<span class="code-quote">"onArrival"</span> 
                  onDeparture=<span class="code-quote">"onDeparture"</span> 
                /&gt;

		<span class="code-tag">&lt;callback transition=<span class="code-quote">"invalidate"</span> method=<span class="code-quote">"stopping"</span> /&gt;</span>
		<span class="code-tag">&lt;callback transition=<span class="code-quote">"validate"</span> method=<span class="code-quote">"starting"</span> /&gt;</span>
	<span class="code-tag">&lt;/component&gt;</span>
<span class="code-tag">&lt;/ipojo&gt;</span>

</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
@org.apache.felix.ipojo.extender.Extender(extension=<span class="code-quote">"My-Extension"</span>, onArrival=<span class="code-quote">"onArrival"</span>, onDeparture=<span class="code-quote">"onDeparture"</span>)
<span class="code-keyword">public</span> class Myextender {
    
    <span class="code-keyword">public</span> void onArrival(Bundle bundle, <span class="code-object">String</span> extension) {
        <span class="code-comment">// handle matching bundle arrival
</span>    }
    
    <span class="code-keyword">public</span> void onDeparture(Bundle bundle) {
        <span class="code-comment">// handler matching bundle departure
</span>    }
}
</pre>
</div></div>
<div class="borderedTable"><div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> extension </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the required extension (i.e. the required Manifest key) </td>
</tr>
<tr>
<td class='confluenceTd'> onArrival </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the method called when a matching bundle arrives. The method receives the Bundle object and the extension value </td>
</tr>
<tr>
<td class='confluenceTd'> onDeparture </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the method called when a matching bundle leaves. The method receives the Bundle object </td>
</tr>
</tbody></table>
</div>
</div>
</div>
<ul>
	<li><a href="/confluence/display/FELIX/Extender+Pattern+Handler" title="Extender Pattern Handler">Extender Pattern Handler</a></li>
</ul>



<h1><a name="iPOJO-Reference-Card-WhiteboardPattern"></a>Whiteboard Pattern</h1>
<ul>
	<li>Allows implementing a <tt>Whiteboard pattern</tt> without handling obscure details</li>
	<li>The whiteboard pattern handler is implemented as an <em>external handlers</em>. To use it, deploy and start the whiteboard pattern handler bundle.</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>XML</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;ipojo <span class="code-keyword">xmlns:wbp</span>=<span class="code-quote">"org.apache.felix.ipojo.whiteboard"</span>&gt;</span>
     &lt;component 
          classname=<span class="code-quote">"org.apache.felix.ipojo.test.MyWhiteBoardPattern"</span>
      &gt;
        &lt;wbp:wbp 
   	      filter=<span class="code-quote">"(my.property=1)"</span> 
              onArrival=<span class="code-quote">"onArrival"</span> 
              onDeparture=<span class="code-quote">"onDeparture"</span> 
              onModification=<span class="code-quote">"onModification"</span>
         /&gt;
       
         <span class="code-tag">&lt;provides/&gt;</span>
      <span class="code-tag">&lt;/component&gt;</span>
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Annotations</b></div><div class="codeContent panelContent">
<pre class="code-java">
@Component
@org.apache.felix.ipojo.whiteboard.Wbp(filter=<span class="code-quote">"(my.property=1)"</span>, 
        onArrival=<span class="code-quote">"onArrival"</span>, 
        onDeparture=<span class="code-quote">"onDeparture"</span>,
        onModification=<span class="code-quote">"onModification"</span>)
<span class="code-keyword">public</span> class WhiteBoardWIModification {
    
    <span class="code-keyword">public</span> void onArrival(ServiceReference ref) {
        <span class="code-comment">// ...
</span>    }
 
    <span class="code-keyword">public</span> void onDeparture(ServiceReference ref) {
        <span class="code-comment">// ...
</span>    }
    
    <span class="code-keyword">public</span> void onModification(ServiceReference ref) {
        <span class="code-comment">// ...
</span>    }

}
</pre>
</div></div>

<div class="" align="center"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Attribute name </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'>&nbsp;</th>
</tr>
<tr>
<td class='confluenceTd'> filter </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies LDAP filter used to detect required service providers </td>
</tr>
<tr>
<td class='confluenceTd'> onArrival </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the method called when a matching service provider arrives. The method receives the ServiceReference object </td>
</tr>
<tr>
<td class='confluenceTd'> onDeparture </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the method called when a matching service provider leaves. The method receives the ServiceReference object </td>
</tr>
<tr>
<td class='confluenceTd'> omModification </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> specifies the method called when a matching service provider is modified and is still matching. The method receives the ServiceReference object </td>
</tr>
</tbody></table>
</div>
</div>

<ul>
	<li><a href="/confluence/display/FELIX/White+Board+Pattern+Handler" title="White Board Pattern Handler">White Board Pattern Handler</a>
<br class="atl-forced-newline" />
<br class="atl-forced-newline" />

 </div>
        <img src="http://felix.apache.org/ipojo/site/footer.png" class="footer">
</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>
</li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/FELIX/iPOJO-Reference-Card">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=105921&revisedVersion=26&originalVersion=25">View Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/FELIX/iPOJO-Reference-Card?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message