felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r849845 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/
Date Fri, 08 Feb 2013 06:49:36 GMT
Author: buildbot
Date: Fri Feb  8 06:49:36 2013
New Revision: 849845

Log:
Staging update by buildbot for felix

Added:
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/handler-arch.png
  (with props)
Modified:
    websites/staging/felix/trunk/content/   (props changed)
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/event-admin-handlers.html

Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Feb  8 06:49:36 2013
@@ -1 +1 @@
-1443567
+1443855

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/event-admin-handlers.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/event-admin-handlers.html
(original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/event-admin-handlers.html
Fri Feb  8 06:49:36 2013
@@ -153,38 +153,61 @@
         <div class="content">
             <h1 id="event-admin-handlers">Event Admin Handlers</h1>
 <p><em>The goal of the Event Admin Handlers is to allow event communications
between iPOJO component instances. The implementation of these handlers relies on an event
admin services. It enables the iPOJO component to listen to a list of topics and to receive
all related events. It also allows components to send events in an easy way.</em></p>
-<p>{div:class=toc}
-[TOC]
-{div}</p>
-<div class="info" markdown="1">
-**change in the 1.2.0**
-The 1.2.0 version use the namespace : `org.apache.felix.ipojo.handlers.event` instead of
`org.apache.felix.ipojo.handlers.event.EventAdminHandler`.
+<div class="toc">
+<ul>
+<li><a href="#event-admin-handlers">Event Admin Handlers</a><ul>
+<li><a href="#an-example">An example</a></li>
+<li><a href="#download">Download</a></li>
+<li><a href="#how-does-it-work">How does it work?</a></li>
+<li><a href="#eventhandler-specification">EventHandler Specification</a><ul>
+<li><a href="#event-subscriber-attributes">Event subscriber attributes</a></li>
+<li><a href="#event-publisher-attributes">Event publisher attributes</a></li>
+<li><a href="#instance-configuration">Instance configuration</a></li>
+<li><a href="#publisher-interface">Publisher interface</a></li>
+</ul>
+</li>
+<li><a href="#handler-architecture">Handler Architecture</a></li>
+<li><a href="#eventhandler-features">EventHandler Features</a><ul>
+<li><a href="#instance-customization">Instance customization</a></li>
+<li><a href="#data-events">Data events</a></li>
+<li><a href="#note-on-synchronous-event-sending">Note on synchronous event sending</a></li>
+<li><a href="#publisher-instance-information">Publisher instance information</a></li>
+<li><a href="#configuring-the-handler-with-annotations">Configuring the handler
with annotations</a></li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+</div>
+<div class="alert alert-warning" markdown="1">
+<strong>change in the 1.2.0</strong>
+<p>The 1.2.0 version use the namespace : <code>org.apache.felix.ipojo.handlers.event</code>
instead of <code>org.apache.felix.ipojo.handlers.event.EventAdminHandler</code>.</p>
 </div>
 
-<div class="info" markdown="1">
-**change in the 1.7.0**
-The `@Publisher` annotation is now deprecated and replaced by `@Publishes`.
+<div class="alert alert-warning" markdown="1">
+<strong>change in the 1.7.0</strong>
+<p>The <code>@Publisher</code> annotation is now deprecated and replaced
by <code>@Publishes</code>.</p>
 </div>
 
 <h2 id="an-example">An example</h2>
 <p>Hereafter is presented a small example :</p>
-<div class="codehilite"><pre><span class="nv">@Component</span>
-<span class="nv">@Instantiate</span>
-<span class="n">public</span> <span class="n">class</span> <span
class="n">MyComponent</span> <span class="p">{</span>
-
-    <span class="nv">@Publishes</span><span class="p">(</span><span
class="sr"> //</span> <span class="ow">or</span> <span class="nv">@Publisher</span>
<span class="n">before</span> <span class="n">the</span> <span
class="mf">1.7.0</span>
-      <span class="n">name</span><span class="o">=</span><span
class="s">&quot;myPublisher&quot;</span><span class="p">,</span>
-      <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;bar,nuts&quot;</span><span class="p">)</span>

-    <span class="n">private</span> <span class="n">Publisher</span>
<span class="n">m_publisher</span><span class="p">;</span>
-
-    <span class="nv">@Subscriber</span><span class="p">(</span>
-      <span class="n">name</span><span class="o">=</span><span
class="s">&quot;mySubscriber&quot;</span><span class="p">,</span>
-      <span class="n">topics</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">receive</span><span class="p">(</span><span class="n">Event</span>
<span class="n">e</span><span class="p">)</span> <span class="p">{</span>
-       <span class="sr">//</span> <span class="n">Event</span> <span
class="n">received</span>
-       <span class="sr">//</span> <span class="n">Do</span> <span
class="n">something</span> <span class="n">with</span> <span class="n">the</span>
<span class="n">event</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<div class="codehilite"><pre><span class="nd">@Component</span>
+<span class="nd">@Instantiate</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">MyComponent</span> <span class="o">{</span>
+
+    <span class="nd">@Publishes</span><span class="o">(</span> <span
class="c1">// or @Publisher before the 1.7.0</span>
+      <span class="n">name</span><span class="o">=</span><span
class="s">&quot;myPublisher&quot;</span><span class="o">,</span>
+      <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;bar,nuts&quot;</span><span class="o">)</span>

+    <span class="kd">private</span> <span class="n">Publisher</span>
<span class="n">m_publisher</span><span class="o">;</span>
+
+    <span class="nd">@Subscriber</span><span class="o">(</span>
+      <span class="n">name</span><span class="o">=</span><span
class="s">&quot;mySubscriber&quot;</span><span class="o">,</span>
+      <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;foo&quot;</span><span class="o">)</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">receive</span><span class="o">(</span><span class="n">Event</span>
<span class="n">e</span><span class="o">)</span> <span class="o">{</span>
+       <span class="c1">// Event received</span>
+       <span class="c1">// Do something with the event</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
@@ -213,43 +236,102 @@ The `@Publisher` annotation is now depre
 <p>The handler will parse the description provided in the metadata, and register for
you the EventHandler in the OSGi Registry. On one hand, your POJO will receive each event
through the handler. With this handler you can specify different callback methods for different
topics. On the other side, the handler instantiates and injects configured Publisher references
in your POJO, so you can send events transparently through these publishers.</p>
 <h2 id="eventhandler-specification">EventHandler Specification</h2>
 <p>Here you can find all configuration options of the EventAdmin handler. As seen before,
the handler contains two components : the event subscriber and the event publisher. These
components can be configured, using several attributes, as described below. Some of these
attributes can be (re)defined in the instance configuration.</p>
-<p><em>Handler namespace :</em> org.apache.felix.ipojo.handlers.event</p>
+<p><em>Handler namespace :</em> <em>org.apache.felix.ipojo.handlers.event</em></p>
 <h3 id="event-subscriber-attributes">Event subscriber attributes</h3>
-<p>{div:class=borderedTable}
-| Attribute name | Required | Description |
-|--|--|--|
-| <em>name</em> | YES | The name of the event subscriber, acting as a unique
          identifier. |
-| <em>callback</em> | YES | The name of the POJO's method that will be called
each time an             event is received. This method takes only one parameter, of typeorg.osgi.service.event.Eventby
default, but this type can be overridden by defining the             data-key and/or the data-type
attributes. |
-| <em>topics</em> | YES* | The 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. |</p>
-<p>If an event is received and it does not contain such a key, it          is ignored
(with a warning message). |</p>
-<p>Data events that are not corresponding to the specified type            will be
ignored (with a warning message). |
-| <em>filter</em> | NO* | The event filter is 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. |
-* These attributes can be (re)defined in the instance configuration.
-{div}</p>
+<table class="table table-bordered">
+    <thead>
+        <tr>
+            <th>Attribute name</th>
+            <th>Required</th>
+            <th>Description</th>
+        </tr>
+    </thead>
+    <tbody>
+        <tr>
+            <td>name</td>
+            <td>yes</td>
+            <td>The name of the event subscriber, acting as a unique identifier.</td>
+        </tr>            
+        <tr>
+            <td>callback</td>
+            <td>yes</td>
+            <td>The name of the POJO's method that will be called each time an event
is received. This method takes only one parameter, of type <code>org.osgi.service.event.Event</code>
by default, but this type can be overridden by defining the data-key and/or the data-type
attributes.</td>
+        </tr>
+        <tr>
+            <td>topics</td>
+            <td>yes</td>
+            <td>The 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. The topics can be set in the instance configuration.</td>
+        </tr>
+        <tr>
+            <td>filter</td>
+            <td>no</td>
+            <td>The event filter is used to filter incoming events before sending them
to the callback. The syntax of this field is described in the OSGi Event Admin Specification.
If you don't specify a filter, all events sent on the listened topics will be considered.
The filter can be set in the instance configuration.</td>
+        </tr>
+        <tr>
+            <td>data-key</td>
+            <td>no</td>
+            <td>The data key is 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. 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 **data-type** 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>data-type</td>
+            <td>no</td>
+            <td>This attribute is associated to the data-key attribute. It specifies
the type of objects (<code>java.lang.Object</code> 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>
+    </tbody>
+</table>
+
 <h3 id="event-publisher-attributes">Event publisher attributes</h3>
-<p>{div:class=borderedTable}
-| Attribute name | Required | Description |
-|--|--|--|
-| <em>name</em> | YES | The name of the event publisher, acting as a unique identifier.
|
-| <em>field</em> | YES | The name of the POJO's field that will be used to send
events.            The field is initialized at component instantiation time. The type    
     of the field must be : org.apache.felix.ipojo.handlers.event.publisher.Publisher. Despite
it creates a dependency between the component code and the handler, this system allows hiding
the             whole complexity of event sending. |
-| <em>topics</em> | YES* | The comma-separated-list of the topics on which events
will be sent. |</p>
-<p>The default value of this attribute is user.data. |</p>
-<p>The default value of this attribute is "false". |
-* These attributes can be (re)defined in the instance configuration.
-{div}</p>
+<p><table class="table table-bordered">
+    <thead>
+        <tr>
+            <th>Attribute name</th>
+            <th>Required</th>
+            <th>Description</th>
+        </tr>
+    </thead>
+    <tbody>
+        <tr>
+            <td>name</td>
+            <td>yes</td>
+            <td>The name of the event publisher, acting as a unique identifier.</td>
+        </tr>          <br />
+        <tr>
+            <td>field</td>
+            <td>yes</td>
+            <td>The name of the POJO's field that will be used to send events. The
field is initialized at component instantiation time. The type of the field must be : <code>org.apache.felix.ipojo.handlers.event.publisher.Publisher</code>.
Despite it creates a dependency between the component code and the handler, this system allows
hiding the whole complexity of event sending.</td>
+        </tr>
+        <tr>
+            <td>topics</td>
+            <td>yes</td>
+            <td>The comma-separated-list of the topics on which events will be sent.
Topics can be set in the instance configuration</td>
+        </tr>
+        <tr>
+            <td>data-key</td>
+            <td>no</td>
+            <td>The data key is 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
<code>sendData</code> method of the Publisher, the given object is placed in the
event dictionary, associated with the specified data-key. The default value of this attribute
is <code>user.data</code>.</td>
+        </tr>
+        <tr>
+            <td>synchronous</td>
+            <td>no</td>
+            <td>Determines if event sending is synchronous or not. By default, events
are sent asynchronously, but you can specify there the desired behaviour of the Publisher.</td>
+        </tr>
+    </tbody>
+</table></p>
 <h3 id="instance-configuration">Instance configuration</h3>
-<p>Some of the described attributes can be (re)defined in the instance configuration
section of your metadata file. Its permits to configure event management instance by instance.
The following properties are used by the handler :
-<em> </em>event.topics<em> : overrides </em>topics<em> attribute,
   available for both subscribers and publishers configuration
-</em> <em>event.filter</em> : overrides <em>filter</em> attribute,
   available for subscribers configuration only.</p>
+<p>Some of the described attributes can be (re)defined in the instance configuration
section of your metadata file. Its permits to configure event management instance by instance.
The following properties are used by the handler :</p>
+<ul>
+<li><em>event.topics</em> : overrides <em>topics</em> attribute,
available for both subscribers and publishers configuration</li>
+<li><em>event.filter</em> : overrides <em>filter</em> attribute,
available for subscribers configuration only.</li>
+</ul>
 <h3 id="publisher-interface">Publisher interface</h3>
-<p>The Publisher interface is the link between the component code and the handler.
It permits to publish events on the topics specified in the component's description (or instance
configuration). The implemented methods are :
-<em> public void send{color:#000000}(Dictionary    content);{color}
-This method is used to send a   standard event, with the specified content. Some specific
properties    may be added in the content to satisfy EventAdmin specification.    (e.g., event.topic).
-</em> public void sendData{color:#000000}(Object    o);{color}
-This method is the easier way to send   data. The given object is placed in the event dictionary
according  to the <em>data-key</em> attribute (or its default value). Then, this
 dictionary is sent as a normal event.</p>
+<p>The Publisher interface is the link between the component code and the handler.
It permits to publish events on the topics specified in the component's description (or instance
configuration). The implemented methods are :</p>
+<ul>
+<li><code>public void send(Dictionary content)</code> : This method is
used to send a    standard event, with the specified content. Some specific properties may
be added in the content to satisfy EventAdmin specification (e.g., event.topic).</li>
+<li><code>public void sendData(Object  o)</code> : This method is the easier
way to send data. The given object is placed in the event dictionary according  to the <em>data-key</em>
attribute (or its default value). Then, this  dictionary is sent as a regular event.</li>
+</ul>
 <h2 id="handler-architecture">Handler Architecture</h2>
 <p>Here is shown the global architecture of the EventHandler : the interactions between
the user components (i.e., POJO), the handler and the OSGi runtime environment.</p>
-<p>!handler-arch.png!</p>
+<p><img src="handler-arch.png"></p>
 <h2 id="eventhandler-features">EventHandler Features</h2>
 <p>In this section, you will find some examples of the handler's features.</p>
 <h3 id="instance-customization">Instance customization</h3>
@@ -287,19 +369,19 @@ This method is the easier way to send   
 
 
 <p>Then you can use the <em>sendData</em> method of your configured publisher.</p>
-<div class="codehilite"><pre><span class="nb">import</span> <span
class="n">org</span><span class="o">.</span><span class="n">apache</span><span
class="o">.</span><span class="n">felix</span><span class="o">.</span><span
class="n">ipojo</span><span class="o">.</span><span class="n">handlers</span><span
class="o">.</span><span class="n">event</span><span class="o">.</span><span
class="n">publisher</span><span class="o">.</span><span class="n">Publisher</span><span
class="p">;</span>
-<span class="sr">//</span><span class="o">...</span>
-<span class="n">public</span> <span class="n">class</span> <span
class="n">DataPublisher</span> <span class="o">...</span> <span class="p">{</span>
-    <span class="n">private</span> <span class="n">Publisher</span>
<span class="n">m_publisher</span><span class="p">;</span>
-
-    <span class="n">public</span> <span class="n">void</span> <span
class="n">doSomething</span><span class="p">()</span> <span class="p">{</span>
-      <span class="sr">//</span> <span class="n">MyFavoriteType</span>
<span class="n">extends</span> <span class="n">MyFavoriteInterface</span>
-      <span class="n">MyFavoriteType</span> <span class="n">data</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">MyFavoriteType</span><span
class="p">(</span><span class="o">...</span><span class="p">);</span>
-      <span class="sr">//</span><span class="o">...</span>
-      <span class="sr">//</span> <span class="n">Send</span> <span
class="n">a</span> <span class="n">data</span> <span class="n">event</span>
-      <span class="n">m_publisher</span><span class="o">.</span><span
class="n">sendData</span><span class="p">(</span><span class="n">data</span><span
class="p">);</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<div class="codehilite"><pre><span class="kn">import</span> <span
class="nn">org.apache.felix.ipojo.handlers.event.publisher.Publisher</span><span
class="o">;</span>
+<span class="c1">//...</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DataPublisher</span> <span class="o">...</span> <span class="o">{</span>
+    <span class="kd">private</span> <span class="n">Publisher</span>
<span class="n">m_publisher</span><span class="o">;</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">doSomething</span><span class="o">()</span> <span class="o">{</span>
+      <span class="c1">// MyFavoriteType extends MyFavoriteInterface</span>
+      <span class="n">MyFavoriteType</span> <span class="n">data</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">MyFavoriteType</span><span
class="o">(...);</span>
+      <span class="c1">//...</span>
+      <span class="c1">// Send a data event</span>
+      <span class="n">m_publisher</span><span class="o">.</span><span
class="na">sendData</span><span class="o">(</span><span class="n">data</span><span
class="o">);</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
@@ -316,63 +398,65 @@ This method is the easier way to send   
     <span class="nt">&lt;/component&gt;</span>
     <span class="nt">&lt;instance</span> <span class="na">component=</span><span
class="s">&quot;...DataEventSubscriber&quot;</span><span class="nt">/&gt;</span>
 <span class="nt">&lt;/ipojo&gt;</span>
+</pre></div>
+
 
-import my.package.MyFavoriteInterface;
-//...
-public class DataEventSubscriber ... {
-  public void handleData(MyFavoriteInterface o) {
-     // Object received
-     //...
-   }
-}
+<p>&nbsp;</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span
class="nn">my.package.MyFavoriteInterface</span><span class="o">;</span>
+<span class="c1">//...</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DataEventSubscriber</span> <span class="o">...</span> <span
class="o">{</span>
+  <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">handleData</span><span class="o">(</span><span class="n">MyFavoriteInterface</span>
<span class="n">o</span><span class="o">)</span> <span class="o">{</span>
+     <span class="c1">// Object received</span>
+     <span class="c1">//...</span>
+   <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
-<p>Annotations use a different set of attributes:
-<em> data-key is replaced by <code>dataKey</code>
-</em> data-type is replaced by <code>dataType</code></p>
+<p>Annotations use a different set of attributes:</p>
+<ul>
+<li>data-key is replaced by <code>dataKey</code></li>
+<li>data-type is replaced by <code>dataType</code></li>
+</ul>
 <h3 id="note-on-synchronous-event-sending">Note on synchronous event sending</h3>
 <p>By default, events are sent using asynchronous sending (a.k.a.<em>post</em>
in OSGi EventAdmin). You can use synchronous sending by defining the <em>synchronous</em>
attribute of your publisher to true.</p>
 <p>The behavior of synchronous event sending is particular when you specify several
topics in the publisher description. The event is synchronously sent to each topic, one by
one. So when you return from this function, you can be sure that the event has been delivered
to each topic.</p>
 <h3 id="publisher-instance-information">Publisher instance information</h3>
 <p>All events sent by a publisher contains the name of the component instance that
sent them. Its enables to filter received events depending the sender instance. The instance
name is accessible in the event dictionary by the key <em>publisher.instance.name</em>.
Despite it goes against MOM principles, this property is useful to trace events and especially
event sources.</p>
 <h3 id="configuring-the-handler-with-annotations">Configuring the handler with annotations</h3>
-<p>It is possible to configure the handler with a simple annotations available in the
annotation pack ('annotation' project in the iPOJO trunk). Here is an example of usage:
-{code:java}
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.event.Subscriber;
-import org.apache.felix.ipojo.handlers.event.Publishes
-import org.apache.felix.ipojo.handlers.event.Publisher;
-import org.osgi.service.event.Event;</p>
-<p>@Component
-public class PubSub {
-    @Publishes(name="p1", synchronous=true)
-    Publisher publisher1;</p>
-<div class="codehilite"><pre><span class="nv">@Publishes</span><span
class="p">(</span><span class="n">name</span><span class="o">=</span><span
class="s">&quot;p2&quot;</span><span class="p">,</span> <span
class="n">synchronous</span><span class="o">=</span><span class="n">false</span><span
class="p">,</span> <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;foo,bar&quot;</span><span class="p">,</span>
<span class="n">data_key</span><span class="o">=</span><span class="s">&quot;data&quot;</span><span
class="p">)</span>
-<span class="n">Publisher</span> <span class="n">publisher2</span><span
class="p">;</span>
-
-<span class="nv">@Publishes</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;p3&quot;</span><span
class="p">,</span> <span class="n">synchronous</span><span class="o">=</span><span
class="n">true</span><span class="p">,</span> <span class="n">topics</span><span
class="o">=</span><span class="s">&quot;bar&quot;</span><span
class="p">)</span>
-<span class="n">Publisher</span> <span class="n">publisher3</span><span
class="p">;</span>
-
-<span class="nv">@Subscriber</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;s1&quot;</span><span
class="p">,</span> <span class="n">data_key</span><span class="o">=</span><span
class="s">&quot;data&quot;</span><span class="p">)</span>
-<span class="n">public</span> <span class="n">void</span> <span
class="n">receive1</span><span class="p">(</span><span class="n">Object</span>
<span class="n">foo</span><span class="p">)</span> <span class="p">{</span>
-    <span class="sr">//</span> <span class="n">Process</span> <span
class="n">event</span>
-<span class="p">}</span>
-
-<span class="nv">@Subscriber</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;s2&quot;</span><span
class="p">,</span> <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;foo,bar&quot;</span><span class="p">,</span>
<span class="n">filter</span><span class="o">=</span><span class="s">&quot;(foo=true)&quot;</span><span
class="p">)</span>
-<span class="n">public</span> <span class="n">void</span> <span
class="n">receive2</span><span class="p">(</span><span class="n">Event</span>
<span class="n">foo</span><span class="p">)</span> <span class="p">{</span>
-    <span class="sr">//</span> <span class="n">Process</span> <span
class="n">event</span>
-<span class="p">}</span>
-
-<span class="nv">@Subscriber</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;s3&quot;</span><span
class="p">,</span> <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;foo&quot;</span><span class="p">,</span> <span
class="n">data</span><span class="o">*</span><span class="n">key</span><span
class="o">=</span><span class="s">&quot;data&quot;</span><span
class="p">,</span> <span class="n">data</span><span class="o">*</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">public</span> <span class="n">void</span> <span
class="n">receive3</span><span class="p">(</span><span class="n">String</span>
<span class="n">foo</span><span class="p">)</span> <span class="p">{</span>
-    <span class="sr">//</span> <span class="n">Process</span> <span
class="n">event</span>
-<span class="p">}</span>
-</pre></div>
-
-
-<p>}</p>
-<div class="codehilite"><pre><span class="o">\\</span>
+<p>It is possible to configure the handler with a simple annotations available in the
annotation pack ('annotation' project in the iPOJO trunk). Here is an example of usage:</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span
class="nn">org.apache.felix.ipojo.annotations.Component</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.felix.ipojo.handlers.event.Subscriber</span><span
class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.felix.ipojo.handlers.event.Publishes</span>
+<span class="kn">import</span> <span class="nn">org.apache.felix.ipojo.handlers.event.Publisher</span><span
class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.osgi.service.event.Event</span><span
class="o">;</span>
+
+<span class="nd">@Component</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">PubSub</span> <span class="o">{</span>
+    <span class="nd">@Publishes</span><span class="o">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;p1&quot;</span><span
class="o">,</span> <span class="n">synchronous</span><span class="o">=</span><span
class="kc">true</span><span class="o">)</span>
+    <span class="n">Publisher</span> <span class="n">publisher1</span><span
class="o">;</span>
+
+    <span class="nd">@Publishes</span><span class="o">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;p2&quot;</span><span
class="o">,</span> <span class="n">synchronous</span><span class="o">=</span><span
class="kc">false</span><span class="o">,</span> <span class="n">topics</span><span
class="o">=</span><span class="s">&quot;foo,bar&quot;</span><span
class="o">,</span> <span class="n">data_key</span><span class="o">=</span><span
class="s">&quot;data&quot;</span><span class="o">)</span>
+    <span class="n">Publisher</span> <span class="n">publisher2</span><span
class="o">;</span>
+
+    <span class="nd">@Publishes</span><span class="o">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;p3&quot;</span><span
class="o">,</span> <span class="n">synchronous</span><span class="o">=</span><span
class="kc">true</span><span class="o">,</span> <span class="n">topics</span><span
class="o">=</span><span class="s">&quot;bar&quot;</span><span
class="o">)</span>
+    <span class="n">Publisher</span> <span class="n">publisher3</span><span
class="o">;</span>
+
+    <span class="nd">@Subscriber</span><span class="o">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;s1&quot;</span><span
class="o">,</span> <span class="n">data_key</span><span class="o">=</span><span
class="s">&quot;data&quot;</span><span class="o">)</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">receive1</span><span class="o">(</span><span class="n">Object</span>
<span class="n">foo</span><span class="o">)</span> <span class="o">{</span>
+        <span class="c1">// Process event</span>
+    <span class="o">}</span>
+
+    <span class="nd">@Subscriber</span><span class="o">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;s2&quot;</span><span
class="o">,</span> <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;foo,bar&quot;</span><span class="o">,</span>
<span class="n">filter</span><span class="o">=</span><span class="s">&quot;(foo=true)&quot;</span><span
class="o">)</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">receive2</span><span class="o">(</span><span class="n">Event</span>
<span class="n">foo</span><span class="o">)</span> <span class="o">{</span>
+        <span class="c1">// Process event</span>
+    <span class="o">}</span>
+
+    <span class="nd">@Subscriber</span><span class="o">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&quot;s3&quot;</span><span
class="o">,</span> <span class="n">topics</span><span class="o">=</span><span
class="s">&quot;foo&quot;</span><span class="o">,</span> <span
class="n">data</span><span class="o">*</span><span class="n">key</span><span
class="o">=</span><span class="s">&quot;data&quot;</span><span
class="o">,</span> <span class="n">data</span><span class="o">*</span><span
class="n">type</span><span class="o">=</span><span class="s">&quot;java.lang.String&quot;</span><span
class="o">)</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">receive3</span><span class="o">(</span><span class="n">String</span>
<span class="n">foo</span><span class="o">)</span> <span class="o">{</span>
+        <span class="c1">// Process event</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
         </div>
     </div>
@@ -388,7 +472,7 @@ public class PubSub {
                 may be trademarks or registered trademarks of their respective owners.
                 </div>
                 <div class="timestamp span3 offset2">
-                Rev. 1441864 by fmeschbe on Sun, 3 Feb 2013 06:44:40 +0000
+                Rev. 1443855 by clement on Fri, 8 Feb 2013 06:49:16 +0000
                 </div>
             </div>
         </footer>           

Added: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/handler-arch.png
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/handler-arch.png
------------------------------------------------------------------------------
    svn:mime-type = image/png



Mime
View raw message