Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 2 | <html><head> |
| 3 | |
| 4 | |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 5 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 6 | <title>Apache Felix - Event Admin Handlers</title> |
| 7 | <link rel="stylesheet" href="event-admin-handlers_files/site.css" type="text/css" media="all"> |
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 9 | </head><body> |
| 10 | <div class="title"><div class="logo"><a href="http://felix.apache.org/site/index.html"><img alt="Apache Felix" src="event-admin-handlers_files/logo.png" border="0"></a></div><div class="header"><a href="http://www.apache.org/"><img alt="Apache" src="event-admin-handlers_files/apache.png" border="0"></a></div></div> |
| 11 | <div class="menu"> |
| 12 | <ul> |
| 13 | <li><a href="http://felix.apache.org/site/news.html" title="news">news</a></li> |
| 14 | <li><a href="http://felix.apache.org/site/license.html" title="license">license</a></li> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 15 | <li><a href="http://felix.apache.org/site/downloads.cgi" rel="nofollow">downloads</a></li> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 16 | <li><a href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</a></li> |
| 17 | <li><a href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</a></li> |
| 18 | <li><a href="http://felix.apache.org/site/contributing.html" title="Contributing">contributing</a></li> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 19 | <li><a href="http://www.apache.org/" rel="nofollow">asf</a></li> |
| 20 | <li><a href="http://www.apache.org/foundation/sponsorship.html" rel="nofollow">sponsorship</a></li> |
| 21 | <li><a href="http://www.apache.org/foundation/thanks.html" rel="nofollow">sponsors</a> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 22 | <!-- ApacheCon Ad --> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 23 | <iframe src="event-admin-handlers_files/button.html" style="border-width: 0pt; float: left;" scrolling="no" frameborder="0" height="135" width="135"></iframe> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 24 | <p style="height: 100px;"> |
| 25 | <!-- ApacheCon Ad --> |
| 26 | </p></li></ul> </div> |
| 27 | <div class="main"> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 28 | <style type="text/css"> |
| 29 | @import url(http://people.apache.org/~clement/ipojo/site/superfish.css); |
| 30 | </style> |
| 31 | |
| 32 | <style type="text/css"> |
| 33 | @import url(http://people.apache.org/~clement/ipojo/site/style.css); |
| 34 | </style> |
| 35 | |
| 36 | <p> |
| 37 | <script class="javascript" src="event-admin-handlers_files/shCore.js"></script> |
| 38 | <script class="javascript" src="event-admin-handlers_files/shBrushCSharp.js"></script> |
| 39 | <script class="javascript" src="event-admin-handlers_files/shBrushPhp.js"></script> |
| 40 | <script class="javascript" src="event-admin-handlers_files/shBrushJScript.js"></script> |
| 41 | <script class="javascript" src="event-admin-handlers_files/shBrushVb.js"></script> |
| 42 | <script class="javascript" src="event-admin-handlers_files/shBrushSql.js"></script> |
| 43 | <script class="javascript" src="event-admin-handlers_files/shBrushXml.js"></script> |
| 44 | <script class="javascript" src="event-admin-handlers_files/shBrushShell.js"></script> |
| 45 | <script class="javascript" src="event-admin-handlers_files/shBrushDelphi.js"></script> |
| 46 | <script class="javascript" src="event-admin-handlers_files/shBrushPython.js"></script> |
| 47 | <script class="javascript" src="event-admin-handlers_files/shBrushJava.js"></script> |
| 48 | |
| 49 | <script type="text/javascript" src="event-admin-handlers_files/jquery-1.js"></script> |
| 50 | <script type="text/javascript" src="event-admin-handlers_files/hoverIntent.js"></script> |
| 51 | <script type="text/javascript" src="event-admin-handlers_files/superfish.js"></script> |
| 52 | <script type="text/javascript" src="event-admin-handlers_files/supersubs.js"></script> |
| 53 | |
| 54 | <script type="text/javascript"> |
| 55 | |
| 56 | $(document).ready(function(){ |
| 57 | $("ul.sf-menu").supersubs({ |
| 58 | minWidth: 14, // minimum width of sub-menus in em units |
| 59 | maxWidth: 30, // maximum width of sub-menus in em units |
| 60 | extraWidth: 1 // extra width can ensure lines don't sometimes turn over |
| 61 | // due to slight rounding differences and font-family |
| 62 | }).superfish(); // call supersubs first, then superfish, so that subs are |
| 63 | // not display:none when measuring. Call before initialising |
| 64 | // containing tabs for same reason. |
| 65 | }); |
| 66 | |
| 67 | </script> |
| 68 | </p><div class="main"> |
| 69 | <div class="page-header"> |
| 70 | <img src="event-admin-handlers_files/header.png" class="header"> |
| 71 | <a href="http://ipojo.org/"><img src="event-admin-handlers_files/ipojo.png" class="header-logo" width="225"></a> |
| 72 | <ul class="sf-menu sf-js-enabled sf-shadow" id="ipojo-menu"> |
| 73 | <li class="current"> |
| 74 | <!-- Menu Overview --> |
| 75 | <a href="" class="sf-with-ul">Overview<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| 76 | <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| 77 | <li style="white-space: normal; float: left; width: 100%;"> |
| 78 | <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo.html" title="Apache Felix iPOJO">Home</a> |
| 79 | </li> |
| 80 | <li style="white-space: normal; float: left; width: 100%;"> |
| 81 | <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-why-choose-ipojo.html" title="apache-felix-ipojo-why-choose-ipojo">Why choose iPOJO</a> |
| 82 | </li> |
| 83 | <li style="white-space: normal; float: left; width: 100%;"> |
| 84 | <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-successstories.html" title="apache-felix-ipojo-successstories">Success stories</a> |
| 85 | </li> |
| 86 | <li style="white-space: normal; float: left; width: 100%;"> |
| 87 | <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-feature-overview.html" title="Apache Felix iPOJO Feature Overview">Features</a> |
| 88 | </li> |
| 89 | </ul> |
| 90 | </li> |
| 91 | |
| 92 | <li class=""> |
| 93 | <!-- Menu download --> |
| 94 | </li><li> |
| 95 | <a href="http://felix.apache.org/site/download.html" title="Download">Download </a> |
| 96 | </li> |
| 97 | |
| 98 | <li class=""> |
| 99 | <!-- Menu Documentation --> |
| 100 | <a href="" class="sf-with-ul">Documentation<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| 101 | <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| 102 | <!-- sub- menu : getting started --> |
| 103 | <li style="white-space: normal; float: left; width: 100%;" class=""> |
| 104 | <a style="float: none; width: auto;" href="" class="sf-with-ul">Getting Started<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| 105 | <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| 106 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-in-10-minutes.html" title="iPOJO in 10 minutes">iPOJO in 10 minutes</a></li> |
| 107 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/how-to-use-ipojo-annotations.html" title="How to use iPOJO Annotations">Using Annotations</a></li> |
| 108 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-hello-word-maven-based-tutorial.html" title="iPOJO Hello Word (Maven-Based) tutorial">Maven tutorial</a></li> |
| 109 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-advanced-tutorial.html" title="iPOJO Advanced Tutorial">Advanced tutorial</a></li> |
| 110 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-dosgi.html" title="apache-felix-ipojo-dosgi">Using Distributed OSGi</a></li> |
| 111 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-composition-tutorial.html" title="iPOJO Composition Tutorial">Application Composition</a></li> |
| 112 | </ul> |
| 113 | </li> <!-- end of getting started --> |
| 114 | <!-- sub menu : Describing Components --> |
| 115 | <li style="white-space: normal; float: left; width: 100%;" class=""> |
| 116 | <a style="float: none; width: auto;" 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><span class="sf-sub-indicator"> »</span></a> |
| 117 | <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| 118 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/service-requirement-handler.html" title="Service Requirement Handler">Requiring a service</a></li> |
| 119 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/providing-osgi-services.html" title="Providing OSGi services">Providing a service</a></li> |
| 120 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/lifecycle-callback-handler.html" title="Lifecycle Callback Handler">Lifecycle management</a></li> |
| 121 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/configuration-handler.html" title="Configuration Handler">Configuration</a></li> |
| 122 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/architecture-handler.html" title="Architecture Handler">Introspection</a></li> |
| 123 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/controller-lifecycle-handler.html" title="Controller Lifecycle Handler">Impacting the lifecycle</a></li> |
| 124 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="" title="Event Admin Handlers">Asynchronous communication</a></li> |
| 125 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-jmx-handler.html" title="iPOJO JMX Handler">JMX management</a></li> |
| 126 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/extender-pattern-handler.html" title="Extender Pattern Handler">Extender pattern</a></li> |
| 127 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/white-board-pattern-handler.html" title="White Board Pattern Handler">Whiteboard pattern</a></li> |
| 128 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/temporal-service-dependency.html" title="Temporal Service Dependency">Temporal dependencies</a></li> |
| 129 | </ul> |
| 130 | </li> <!-- End of describing components --> |
| 131 | <!-- sub- menu : User Guide --> |
| 132 | <li style="white-space: normal; float: left; width: 100%;" class=""> |
| 133 | <a style="float: none; width: auto;" href="" class="sf-with-ul">User Guide<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| 134 | <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| 135 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/using-xml-schemas.html" title="Using XML Schemas">XML Schemas</a></li> |
| 136 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-api.html" title="apache-felix-ipojo-api">API</a></li> |
| 137 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-testing-components.html" title="apache-felix-ipojo-testing-components">Testing components</a></li> |
| 138 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-eclipse-integration.html" title="apache-felix-ipojo-eclipse-integration">Eclipse Integration</a></li> |
| 139 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-faq.html" title="iPOJO FAQ">FAQ</a></li> |
| 140 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-reference-card.html" title="iPOJO-Reference-Card">Reference Card</a></li> |
| 141 | </ul> |
| 142 | </li> <!-- end of user guide --> |
| 143 | <!-- sub- menu : Dev Guide --> |
| 144 | <li class="" style="white-space: normal; float: left; width: 100%;"> |
| 145 | <a style="float: none; width: auto;" href="" class="sf-with-ul">Advanced Topics<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| 146 | <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| 147 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/ipojo/api/1.2.0" rel="nofollow">Javadoc</a></li> |
| 148 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/how-to-write-your-own-handler.html" title="How to write your own handler">Handler guide</a></li> |
| 149 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/how-to-use-ipojo-manipulation-metadata.html" title="How to use iPOJO Manipulation Metadata">Manipulation Metadata </a></li> |
| 150 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/dive-into-the-ipojo-manipulation-depths.html" title="Dive into the iPOJO Manipulation depths">Dive into the iPOJO Manipulation depths</a></li> |
| 151 | </ul> |
| 152 | </li> <!-- End of Dev guide --> |
| 153 | </ul> |
| 154 | </li> <!-- End of doc --> |
| 155 | <!-- Menu 4 : Tools --> |
| 156 | <li class=""> |
| 157 | <a href="" class="sf-with-ul">Tools<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| 158 | <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| 159 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-ant-task.html" title="iPOJO Ant Task">Ant Task</a></li> |
| 160 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-eclipse-plug-in.html" title="iPOJO Eclipse Plug-in">Eclipse Plugin</a></li> |
| 161 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-maven-plug-in.html" title="iPOJO Maven Plug-in">Maven Plugin</a></li> |
| 162 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-online-manipulator.html" title="apache-felix-ipojo-online-manipulator">Online Manipulator</a></li> |
| 163 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-webconsole-plugin.html" title="iPOJO Webconsole Plugin">Webconsole plugin</a></li> |
| 164 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-junit4osgi.html" title="apache-felix-ipojo-junit4osgi">Junit4OSGi</a></li> |
| 165 | </ul> |
| 166 | </li><!-- End of tools --> |
| 167 | <!-- Menu 5 : Misc --> |
| 168 | <li class=""> |
| 169 | <a href="" class="sf-with-ul">Misc<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| 170 | <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| 171 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-issuestracker.html" title="apache-felix-ipojo-issuestracker">Issues Tracker</a></li> |
| 172 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-supportedvms.html" title="apache-felix-ipojo-supportedVMs">Supported JVMs</a></li> |
| 173 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-supportedosgi.html" title="apache-felix-ipojo-supportedOSGi">Supported OSGi Implementations</a></li> |
| 174 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://ipojo-dark-side.blogspot.com/" rel="nofollow">iPOJO's Dark Side Blog</a></li> |
| 175 | <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/article-presentations.html" title="Article & Presentations">Article & Presentations</a></li> |
| 176 | </ul> |
| 177 | </li><!-- End of misc --> |
| 178 | </ul> <!-- End of the menu --> |
| 179 | </div> <!-- Page header --> |
| 180 | |
| 181 | |
| 182 | <div class="content"> |
| 183 | |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 184 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 185 | <h1><a name="EventAdminHandlers-EventAdminHandlers"></a>Event Admin Handlers</h1> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 186 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 187 | <p><em>The goal of the Event Admin Handlers is to allow event |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 188 | communications between iPOJO component instances. The implementation of |
| 189 | these handlers relies on an event admin services. It enables the iPOJO |
| 190 | component to listen to a list of topics and to receive all related |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 191 | event. It also allows components to send events in an easy way.</em></p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 192 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 193 | <div class="toc"> |
| 194 | <ul> |
| 195 | <li><a href="#EventAdminHandlers-Anexample">An example</a></li> |
| 196 | <li><a href="#EventAdminHandlers-Download">Download</a></li> |
| 197 | <li><a href="#EventAdminHandlers-Howdoesitwork%253F">How does it work?</a></li> |
| 198 | <li><a href="#EventAdminHandlers-EventHandlerSpecification">EventHandler Specification</a></li> |
| 199 | <ul> |
| 200 | <li><a href="#EventAdminHandlers-Eventsubscriberattributes">Event subscriber attributes</a></li> |
| 201 | <li><a href="#EventAdminHandlers-Eventpublisherattributes">Event publisher attributes</a></li> |
| 202 | <li><a href="#EventAdminHandlers-Instanceconfiguration">Instance configuration</a></li> |
| 203 | <li><a href="#EventAdminHandlers-Publisherinterface">Publisher interface</a></li> |
| 204 | </ul> |
| 205 | <li><a href="#EventAdminHandlers-HandlerArchitecture">Handler Architecture</a></li> |
| 206 | <li><a href="#EventAdminHandlers-EventHandlerFeatures">EventHandler Features</a></li> |
| 207 | <ul> |
| 208 | <li><a href="#EventAdminHandlers-Instancecustomization">Instance customization</a></li> |
| 209 | <li><a href="#EventAdminHandlers-Dataevents">Data events</a></li> |
| 210 | <li><a href="#EventAdminHandlers-Noteonsynchronouseventsending">Note on synchronous event sending</a></li> |
| 211 | <li><a href="#EventAdminHandlers-Publisherinstanceinformation">Publisher instance information</a></li> |
| 212 | <li><a href="#EventAdminHandlers-Configuringthehandlerwithannotations">Configuring the handler with annotations</a></li> |
| 213 | </ul> |
| 214 | </ul></div> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 215 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 216 | <div class="panelMacro"><table class="infoMacro"><colgroup><col width="24"><col></colgroup><tbody><tr><td valign="top"><img src="event-admin-handlers_files/information.gif" alt="" border="0" align="absmiddle" height="16" width="16"></td><td><b>change in the 1.2.0</b><br><p>The 1.2.0 version use the namespace : <tt>org.apache.felix.ipojo.handlers.event</tt> instead of <tt>org.apache.felix.ipojo.handlers.event.EventAdminHandler</tt></p></td></tr></tbody></table></div> |
| 217 | |
| 218 | <h2><a name="EventAdminHandlers-Anexample"></a>An example</h2> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 219 | <p>Hereafter is presented a small example of the metadata.xml file :</p> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 220 | <div class="code"> |
| 221 | <div class="dp-highlighter"><table class="dp-xml" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="tag"><</span><span>ipojo </span></td></tr><tr><td class="line2"> xmlns:<span class="attribute">ev</span><span>=</span><span class="attribute-value">"org.apache.felix.ipojo.handlers.event"</span><span>> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>component </span><span class="attribute">className</span><span>=</span><span class="attribute-value">"...MyComponent"</span><span>> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>ev:subscriber </span></td></tr><tr><td class="line1"> <span class="attribute">name</span><span>=</span><span class="attribute-value">"mySubscriber"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">callback</span><span>=</span><span class="attribute-value">"receive"</span><span> </span></td></tr><tr><td class="line1"> <span class="attribute">topics</span><span>=</span><span class="attribute-value">"foo"</span><span>/> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>ev:publisher </span></td></tr><tr><td class="line1"> <span class="attribute">name</span><span>=</span><span class="attribute-value">"myPublisher"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">field</span><span>=</span><span class="attribute-value">"m_publisher"</span><span> </span></td></tr><tr><td class="line1"> <span class="attribute">topics</span><span>=</span><span class="attribute-value">"bar,nuts"</span><span>/> </span></td></tr><tr><td class="line2"> <span class="tag"></</span><span>component</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>instance </span><span class="attribute">component</span><span>=</span><span class="attribute-value">"...MyComponent"</span><span>/> </span></td></tr><tr><td class="line2"><span class="tag"></</span><span>ipojo</span><span class="tag">></span><span> </span></td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><ipojo |
| 222 | xmlns:ev="org.apache.felix.ipojo.handlers.event"> |
| 223 | <component className="...MyComponent"> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 224 | <ev:subscriber |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 225 | name="mySubscriber" |
| 226 | callback="receive" |
| 227 | topics="foo"/> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 228 | <ev:publisher |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 229 | name="myPublisher" |
| 230 | field="m_publisher" |
| 231 | topics="bar,nuts"/> |
| 232 | </component> |
| 233 | <instance component="...MyComponent"/> |
| 234 | </ipojo></textarea> |
| 235 | <script class="javascript"> |
| 236 | if(!window.newcodemacro_initialised) |
| 237 | { |
| 238 | window.newcodemacro_initialised = true; |
| 239 | window.oldonloadmethod = window.onload; |
| 240 | window.onload = function(){ |
| 241 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 242 | if(window.oldonloadmethod) |
| 243 | { |
| 244 | window.oldonloadmethod(); |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | </script> |
| 250 | </div> |
| 251 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 252 | <p>You need to specify the namespace of the Handler. You can find here |
| 253 | one event subscriber (named mySubscriber) and one event publisher |
| 254 | (named myPublisher). In these handler configurations, the name |
| 255 | parameter is mandatory. The topics parameter is optional as it can be |
| 256 | specified in the instance configuration. The callback parameter of the |
| 257 | mySubscriber element is mandatory and indicates the method that handles |
| 258 | received events. In this case, this method must have a single argument |
| 259 | of type org.osgi.service.event.Event. The field parameter of the |
| 260 | myPublisher element indicates the field (of type |
| 261 | org.apache.felix.ipojo.handlers.event.publisher.Publisher) that is used |
| 262 | by the POJO to send events on the specified topics. All type compliance |
| 263 | will be checked by the handler at component instantiation time.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 264 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 265 | <p>Here is an example of the component implementation, compatible with the given description :</p> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 266 | <div class="code"> |
| 267 | <div class="dp-highlighter"><table class="dp-c" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="keyword">import</span><span> org.apache.felix.ipojo.handlers.event.publisher.Publisher; </span></td></tr><tr><td class="line2"><span class="keyword">import</span><span> org.osgi.service.event.Event; </span></td></tr><tr><td class="line1"> </td></tr><tr><td class="line2"><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> MyComponent ... { </span></td></tr><tr><td class="line1"> <span class="keyword">private</span><span> Publisher m_publisher; </span></td></tr><tr><td class="line2"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> receive(Event e) { </span></td></tr><tr><td class="line1"> <span class="comment">// Event received</span><span> </span></td></tr><tr><td class="line2"> <span class="comment">// Do something with the event}</span><span> </span></td></tr><tr><td class="line1"> </td></tr><tr><td class="line2"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> doSomething() { </span></td></tr><tr><td class="line1"> Dictionary e = new Properties(); </td></tr><tr><td class="line2"> <span class="comment">//...</span><span> </span></td></tr><tr><td class="line1"> <span class="comment">// Fill out the event</span><span> </span></td></tr><tr><td class="line2"> </td></tr><tr><td class="line1"> <span class="comment">// Send event</span><span> </span></td></tr><tr><td class="line2"> m_publisher.send(e); </td></tr><tr><td class="line1"> } </td></tr><tr><td class="line2">} </td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">import org.apache.felix.ipojo.handlers.event.publisher.Publisher; |
| 268 | import org.osgi.service.event.Event; |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 269 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 270 | public class MyComponent ... { |
| 271 | private Publisher m_publisher; |
| 272 | public void receive(Event e) { |
| 273 | // Event received |
| 274 | // Do something with the event} |
| 275 | |
| 276 | public void doSomething() { |
| 277 | Dictionary e = new Properties(); |
| 278 | //... |
| 279 | // Fill out the event |
| 280 | |
| 281 | // Send event |
| 282 | m_publisher.send(e); |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 283 | } |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 284 | }</textarea> |
| 285 | <script class="javascript"> |
| 286 | if(!window.newcodemacro_initialised) |
| 287 | { |
| 288 | window.newcodemacro_initialised = true; |
| 289 | window.oldonloadmethod = window.onload; |
| 290 | window.onload = function(){ |
| 291 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 292 | if(window.oldonloadmethod) |
| 293 | { |
| 294 | window.oldonloadmethod(); |
| 295 | } |
| 296 | } |
| 297 | } |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 298 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 299 | </script> |
| 300 | </div> |
| 301 | |
| 302 | |
| 303 | <h2><a name="EventAdminHandlers-Download"></a>Download</h2> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 304 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 305 | <p>The event admin handlers (to send and receive events) are available in the Felix trunk in the iPOJO project. See the <a href="http://felix.apache.org/site/download.html" title="Download">Download</a> page to download and compile these sources.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 306 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 307 | <h2><a name="EventAdminHandlers-Howdoesitwork?"></a>How does it work?</h2> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 308 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 309 | <p>The handler will parse the description provided in the metadata, and |
| 310 | register for you the EventHandler in the OSGi Registry. On one hand, |
| 311 | your POJO will receive each event through the handler. With this |
| 312 | handler you can specify different callback methods for different |
| 313 | topics. On the other side, the handler instantiates and injects |
| 314 | configured Publisher references in your POJO, so you can send events |
| 315 | transparently through these publishers.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 316 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 317 | <h2><a name="EventAdminHandlers-EventHandlerSpecification"></a>EventHandler Specification</h2> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 318 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 319 | <p>Here you can find all configuration options of the EventAdmin |
| 320 | handler. As seen before, the handler contains two components : the |
| 321 | event subscriber and the event publisher. These components can be |
| 322 | configured, using several attributes, as described below. Some of these |
| 323 | attributes can be (re)defined in the instance configuration.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 324 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 325 | <p><b>Handler namespace :</b> org.apache.felix.ipojo.handlers.event</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 326 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 327 | <h3><a name="EventAdminHandlers-Eventsubscriberattributes"></a>Event subscriber attributes</h3> |
| 328 | <div class="borderedTable"><table class="confluenceTable"><tbody> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 329 | <tr> |
| 330 | <th class="confluenceTh"> Attribute name </th> |
| 331 | <th class="confluenceTh"> Required </th> |
| 332 | <th class="confluenceTh"> Description </th> |
| 333 | </tr> |
| 334 | <tr> |
| 335 | <td class="confluenceTd"> <em>name</em> </td> |
| 336 | <td class="confluenceTd"> YES </td> |
| 337 | <td class="confluenceTd"> The name of the event subscriber, acting as a unique identifier. </td> |
| 338 | </tr> |
| 339 | <tr> |
| 340 | <td class="confluenceTd"> <em>callback</em> </td> |
| 341 | <td class="confluenceTd"> YES </td> |
| 342 | <td class="confluenceTd"> The name of the POJO's method that will be |
| 343 | called each time an event is received. This method takes only one |
| 344 | parameter, of typeorg.osgi.service.event.Eventby default, but this type |
| 345 | can be overridden by defining the data-key and/or the data-type |
| 346 | attributes. </td> |
| 347 | </tr> |
| 348 | <tr> |
| 349 | <td class="confluenceTd"> <em>topics</em> </td> |
| 350 | <td class="confluenceTd"> YES* </td> |
| 351 | <td class="confluenceTd"> The comma-separated-list of the topics that |
| 352 | the handler will listen to. Each event sent on a topic present in this |
| 353 | list will be sent to the specified callback method. </td> |
| 354 | </tr> |
| 355 | <tr> |
| 356 | <td class="confluenceTd"> <em>data-key</em> </td> |
| 357 | <td class="confluenceTd"> NO </td> |
| 358 | <td class="confluenceTd"> The data key is used when you want to receive |
| 359 | data events. This attribute's value is the key corresponding to the |
| 360 | received data in the event's dictionary. <br clear="all"> |
| 361 | If you use this attribute, the parameter passed to the callback method |
| 362 | is the the value associated to this key, not the whole event. <br clear="all"> |
| 363 | This attribute is generally used with the <em>data-type</em> attribute to specify the received object type. <br clear="all"> |
| 364 | If an event is received and it does not contain such a key, it is ignored (with a warning message). </td> |
| 365 | </tr> |
| 366 | <tr> |
| 367 | <td class="confluenceTd"> <em>data-type</em> </td> |
| 368 | <td class="confluenceTd"> NO </td> |
| 369 | <td class="confluenceTd"> This attribute is associated to the data-key |
| 370 | attribute. It specifies the type of objects (java.lang.Objectby |
| 371 | default) that the callback expects. It is used to determine the unique |
| 372 | callback method (in case of multiple methods with the same name) and to |
| 373 | check type compliance at event reception. <br clear="all"> |
| 374 | Data events that are not corresponding to the specified type will be ignored (with a warning message). </td> |
| 375 | </tr> |
| 376 | <tr> |
| 377 | <td class="confluenceTd"> <em>filter</em> </td> |
| 378 | <td class="confluenceTd"> NO* </td> |
| 379 | <td class="confluenceTd"> The event filter is used to filter incoming |
| 380 | events before sending them to the callback. The syntax of this field is |
| 381 | described in the OSGi EventAdmin Specification. If you don't specify a |
| 382 | filter, all events sent on the listened topics will be considered. </td> |
| 383 | </tr> |
| 384 | </tbody></table> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 385 | <p>* These attributes can be (re)defined in the instance configuration.</p></div> |
| 386 | <h3><a name="EventAdminHandlers-Eventpublisherattributes"></a>Event publisher attributes</h3> |
| 387 | <div class="borderedTable"><table class="confluenceTable"><tbody> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 388 | <tr> |
| 389 | <th class="confluenceTh"> Attribute name </th> |
| 390 | <th class="confluenceTh"> Required </th> |
| 391 | <th class="confluenceTh"> Description </th> |
| 392 | </tr> |
| 393 | <tr> |
| 394 | <td class="confluenceTd"> <em>name</em> </td> |
| 395 | <td class="confluenceTd"> YES </td> |
| 396 | <td class="confluenceTd"> The name of the event publisher, acting as a unique identifier. </td> |
| 397 | </tr> |
| 398 | <tr> |
| 399 | <td class="confluenceTd"> <em>field</em> </td> |
| 400 | <td class="confluenceTd"> YES </td> |
| 401 | <td class="confluenceTd"> The name of the POJO's field that will be |
| 402 | used to send events. The field is initialized at component |
| 403 | instantiation time. The type of the field must be : |
| 404 | org.apache.felix.ipojo.handlers.event.publisher.Publisher. Despite it |
| 405 | creates a dependency between the component code and the handler, this |
| 406 | system allows hiding the whole complexity of event sending. </td> |
| 407 | </tr> |
| 408 | <tr> |
| 409 | <td class="confluenceTd"> <em>topics</em> </td> |
| 410 | <td class="confluenceTd"> YES* </td> |
| 411 | <td class="confluenceTd"> The comma-separated-list of the topics on which events will be sent. </td> |
| 412 | </tr> |
| 413 | <tr> |
| 414 | <td class="confluenceTd"> <em>data-key</em> </td> |
| 415 | <td class="confluenceTd"> NO </td> |
| 416 | <td class="confluenceTd"> The data key is used when you want to send |
| 417 | data events. This attribute's value is the key, in the event's |
| 418 | 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. <br clear="all"> |
| 419 | The default value of this attribute is user.data. </td> |
| 420 | </tr> |
| 421 | <tr> |
| 422 | <td class="confluenceTd"> <em>synchronous</em> </td> |
| 423 | <td class="confluenceTd"> NO </td> |
| 424 | <td class="confluenceTd"> Determines if event sending is synchronous or |
| 425 | not. By default, events are sent asynchronously, but you can specify |
| 426 | there the desired behaviour of the Publisher. <br clear="all"> |
| 427 | The default value of this attribute is "false". </td> |
| 428 | </tr> |
| 429 | </tbody></table> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 430 | <p>* These attributes can be (re)defined in the instance configuration.</p></div> |
| 431 | <h3><a name="EventAdminHandlers-Instanceconfiguration"></a>Instance configuration</h3> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 432 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 433 | <p>Some of the described attributes can be (re)defined in the instance |
| 434 | configuration section of your metadata file. Its permits to configure |
| 435 | event management instance by instance. The following properties are |
| 436 | used by the handler :</p> |
| 437 | <ul> |
| 438 | <li><em>event.topics</em> : overrides <em>topics</em> attribute, available for both subscribers and publishers configuration</li> |
| 439 | <li><em>event.filter</em> : overrides <em>filter</em> attribute, available for subscribers configuration only.</li> |
| 440 | </ul> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 441 | |
| 442 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 443 | <h3><a name="EventAdminHandlers-Publisherinterface"></a>Publisher interface</h3> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 444 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 445 | <p>The Publisher interface is the link between the component code and |
| 446 | the handler. It permits to publish events on the topics specified in |
| 447 | the component's description (or instance configuration). The |
| 448 | implemented methods are :</p> |
| 449 | <ul> |
| 450 | <li>public void send<font color="#000000">(Dictionary content);</font><br> |
| 451 | This method is used to send a standard event, with the specified |
| 452 | content. Some specific properties may be added in the content to |
| 453 | satisfy EventAdmin specification. (e.g., event.topic).</li> |
| 454 | <li>public void sendData<font color="#000000">(Object o);</font><br> |
| 455 | 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.</li> |
| 456 | </ul> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 457 | |
| 458 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 459 | <h2><a name="EventAdminHandlers-HandlerArchitecture"></a>Handler Architecture</h2> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 460 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 461 | <p>Here is shown the global architecture of the EventHandler : the |
| 462 | interactions between the user components (i.e., POJO), the handler and |
| 463 | the OSGi runtime environment.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 464 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 465 | <p><img src="event-admin-handlers_files/handler-arch.png" border="0" align="absmiddle"></p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 466 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 467 | <h2><a name="EventAdminHandlers-EventHandlerFeatures"></a>EventHandler Features</h2> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 468 | <p>In this section, you will find some examples of the handler's features.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 469 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 470 | <h3><a name="EventAdminHandlers-Instancecustomization"></a>Instance customization</h3> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 471 | <p>As described in the 'Instance configuration' section, you can |
| 472 | (re)define some of the subscribers or publishers attributes. You can |
| 473 | notice that required attributes that are not defined in the component |
| 474 | description must be defined in the instance configuration section. |
| 475 | Hereafter is an example of an instance configuration of this handler :</p> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 476 | <div class="code"> |
| 477 | <div class="dp-highlighter"><table class="dp-xml" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="tag"><</span><span>ipojo </span></td></tr><tr><td class="line2"> xmlns:<span class="attribute">ev</span><span>=</span><span class="attribute-value">"org.apache.felix.ipojo.handlers.event"</span><span>> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>component </span><span class="attribute">className</span><span>=</span><span class="attribute-value">"...MyComponent"</span><span>> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>ev:subscriber </span></td></tr><tr><td class="line1"> <span class="attribute">name</span><span>=</span><span class="attribute-value">"mySubscriber"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">callback</span><span>=</span><span class="attribute-value">"handleEvent"</span><span>/> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>ev:publisher </span></td></tr><tr><td class="line2"> <span class="attribute">name</span><span>=</span><span class="attribute-value">"myPublisher"</span><span> </span></td></tr><tr><td class="line1"> <span class="attribute">field</span><span>=</span><span class="attribute-value">"m_publisher"</span><span>/> </span></td></tr><tr><td class="line2"> <span class="tag"></</span><span>component</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>instance </span><span class="attribute">component</span><span>=</span><span class="attribute-value">"...MyComponent"</span><span>> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>property </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"event.topics"</span><span>> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>property </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"mySubscriber"</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"foo"</span><span>/> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>property </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"myPublisher"</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"bar,nuts"</span><span>/> </span></td></tr><tr><td class="line1"> <span class="tag"></</span><span>property</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>property </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"event.filter"</span><span>> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>property </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"mySubscriber"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">value</span><span>=</span><span class="attribute-value">"|((arg=Minibar)(arg=Coconuts))"</span><span>/> </span></td></tr><tr><td class="line1"> <span class="tag"></</span><span>property</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"></</span><span>instance</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"><span class="tag"></</span><span>ipojo</span><span class="tag">></span><span> </span></td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><ipojo |
| 478 | xmlns:ev="org.apache.felix.ipojo.handlers.event"> |
| 479 | <component className="...MyComponent"> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 480 | <ev:subscriber |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 481 | name="mySubscriber" |
| 482 | callback="handleEvent"/> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 483 | <ev:publisher |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 484 | name="myPublisher" |
| 485 | field="m_publisher"/> |
| 486 | </component> |
| 487 | <instance component="...MyComponent"> |
| 488 | <property name="event.topics"> |
| 489 | <property name="mySubscriber" value="foo"/> |
| 490 | <property name="myPublisher" value="bar,nuts"/> |
| 491 | </property> |
| 492 | <property name="event.filter"> |
| 493 | <property name="mySubscriber" |
| 494 | value="|((arg=Minibar)(arg=Coconuts))"/> |
| 495 | </property> |
| 496 | </instance> |
| 497 | </ipojo></textarea> |
| 498 | <script class="javascript"> |
| 499 | if(!window.newcodemacro_initialised) |
| 500 | { |
| 501 | window.newcodemacro_initialised = true; |
| 502 | window.oldonloadmethod = window.onload; |
| 503 | window.onload = function(){ |
| 504 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 505 | if(window.oldonloadmethod) |
| 506 | { |
| 507 | window.oldonloadmethod(); |
| 508 | } |
| 509 | } |
| 510 | } |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 511 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 512 | </script> |
| 513 | </div> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 514 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 515 | |
| 516 | <h3><a name="EventAdminHandlers-Dataevents"></a>Data events</h3> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 517 | <p>One of the most important features of the EventHandler is the |
| 518 | capability of sending and receiving data events. You may know that the |
| 519 | OSGi EventAdmin Service allows bundles to send custom objects in |
| 520 | events, inserting them in the event's dictionary. The EventHandler |
| 521 | hides the dictionary manipulation and allows iPOJO components to |
| 522 | receive custom objects at any time.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 523 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 524 | <p>First, you have define the <em>data-key</em> attribute in the |
| 525 | publisher configuration. Sent objects will be contained in the event |
| 526 | dictionary and are accessible with the "user.data" key.</p> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 527 | <div class="code"> |
| 528 | <div class="dp-highlighter"><table class="dp-xml" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="tag"><</span><span>ipojo </span></td></tr><tr><td class="line2"> xmlns:<span class="attribute">ev</span><span>=</span><span class="attribute-value">"org.apache.felix.ipojo.handlers.event"</span><span>> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>component </span><span class="attribute">className</span><span>=</span><span class="attribute-value">"...DataPublisher"</span><span>> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>ev:publisher </span></td></tr><tr><td class="line1"> <span class="attribute">name</span><span>=</span><span class="attribute-value">"myPublisher"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">field</span><span>=</span><span class="attribute-value">"m_publisher"</span><span> </span></td></tr><tr><td class="line1"> <span class="attribute">topics</span><span>=</span><span class="attribute-value">"myTopic"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">data-key</span><span>=</span><span class="attribute-value">"my.data"</span><span>/> </span></td></tr><tr><td class="line1"> <span class="tag"></</span><span>component</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>instance </span><span class="attribute">component</span><span>=</span><span class="attribute-value">"...DataPublisher"</span><span>/> </span></td></tr><tr><td class="line1"><span class="tag"></</span><span>ipojo</span><span class="tag">></span><span> </span></td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><ipojo |
| 529 | xmlns:ev="org.apache.felix.ipojo.handlers.event"> |
| 530 | <component className="...DataPublisher"> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 531 | <ev:publisher |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 532 | name="myPublisher" |
| 533 | field="m_publisher" |
| 534 | topics="myTopic" |
| 535 | data-key="my.data"/> |
| 536 | </component> |
| 537 | <instance component="...DataPublisher"/> |
| 538 | </ipojo></textarea> |
| 539 | <script class="javascript"> |
| 540 | if(!window.newcodemacro_initialised) |
| 541 | { |
| 542 | window.newcodemacro_initialised = true; |
| 543 | window.oldonloadmethod = window.onload; |
| 544 | window.onload = function(){ |
| 545 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 546 | if(window.oldonloadmethod) |
| 547 | { |
| 548 | window.oldonloadmethod(); |
| 549 | } |
| 550 | } |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 551 | } |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 552 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 553 | </script> |
| 554 | </div> |
| 555 | |
| 556 | <p>Then you can use the <em>sendData</em> method of your configured publisher.</p> |
| 557 | <div class="code"> |
| 558 | <div class="dp-highlighter"><table class="dp-c" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="keyword">import</span><span> org.apache.felix.ipojo.handlers.event.publisher.Publisher; </span></td></tr><tr><td class="line2"><span class="comment">//...</span><span> </span></td></tr><tr><td class="line1"><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> DataPublisher ... { </span></td></tr><tr><td class="line2"> <span class="keyword">private</span><span> Publisher m_publisher; </span></td></tr><tr><td class="line1"> </td></tr><tr><td class="line2"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> doSomething() { </span></td></tr><tr><td class="line1"> <span class="comment">// MyFavoriteType extends MyFavoriteInterface</span><span> </span></td></tr><tr><td class="line2"> MyFavoriteType data = new MyFavoriteType(...); </td></tr><tr><td class="line1"> <span class="comment">//...</span><span> </span></td></tr><tr><td class="line2"> <span class="comment">// Send a data event</span><span> </span></td></tr><tr><td class="line1"> m_publisher.sendData(data); </td></tr><tr><td class="line2"> } </td></tr><tr><td class="line1">} </td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">import org.apache.felix.ipojo.handlers.event.publisher.Publisher; |
| 559 | //... |
| 560 | public class DataPublisher ... { |
| 561 | private Publisher m_publisher; |
| 562 | |
| 563 | public void doSomething() { |
| 564 | // MyFavoriteType extends MyFavoriteInterface |
| 565 | MyFavoriteType data = new MyFavoriteType(...); |
| 566 | //... |
| 567 | // Send a data event |
| 568 | m_publisher.sendData(data); |
| 569 | } |
| 570 | }</textarea> |
| 571 | <script class="javascript"> |
| 572 | if(!window.newcodemacro_initialised) |
| 573 | { |
| 574 | window.newcodemacro_initialised = true; |
| 575 | window.oldonloadmethod = window.onload; |
| 576 | window.onload = function(){ |
| 577 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 578 | if(window.oldonloadmethod) |
| 579 | { |
| 580 | window.oldonloadmethod(); |
| 581 | } |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | </script> |
| 586 | </div> |
| 587 | |
| 588 | <p>The second step is to configure an event subscriber to receive such events. The <em>data-key</em> attribute's value of the subscriber must be the same than the publisher's one. The <em>data-type</em> |
| 589 | describes the type of received data events, and thus, must be |
| 590 | compatible with the sent object's type (i.e., super-class or inherited |
| 591 | interface). Then you can finally receive the sent object in the |
| 592 | callback method. The parameter type of the callback must be the same |
| 593 | than the data-type attribute value.</p> |
| 594 | <div class="code"> |
| 595 | <div class="dp-highlighter"><table class="dp-xml" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="tag"><</span><span>ipojo </span></td></tr><tr><td class="line2"> xmlns:<span class="attribute">ev</span><span>=</span><span class="attribute-value">"org.apache.felix.ipojo.handlers.event"</span><span>> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>component </span><span class="attribute">className</span><span>=</span><span class="attribute-value">"...DataEventSubscriber"</span><span>> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>ev:subscriber </span></td></tr><tr><td class="line1"> <span class="attribute">name</span><span>=</span><span class="attribute-value">"mySubscriber"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">callback</span><span>=</span><span class="attribute-value">"handleData"</span><span> </span></td></tr><tr><td class="line1"> <span class="attribute">topics</span><span>=</span><span class="attribute-value">"myTopic"</span><span> </span></td></tr><tr><td class="line2"> <span class="attribute">data-key</span><span>=</span><span class="attribute-value">"my.data"</span><span> </span></td></tr><tr><td class="line1"> <span class="attribute">data-type</span><span>=</span><span class="attribute-value">"my.package.MyFavoriteInterface"</span><span>/> </span></td></tr><tr><td class="line2"> <span class="tag"></</span><span>component</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>instance </span><span class="attribute">component</span><span>=</span><span class="attribute-value">"...DataEventSubscriber"</span><span>/> </span></td></tr><tr><td class="line2"><span class="tag"></</span><span>ipojo</span><span class="tag">></span><span> </span></td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><ipojo |
| 596 | xmlns:ev="org.apache.felix.ipojo.handlers.event"> |
| 597 | <component className="...DataEventSubscriber"> |
| 598 | <ev:subscriber |
| 599 | name="mySubscriber" |
| 600 | callback="handleData" |
| 601 | topics="myTopic" |
| 602 | data-key="my.data" |
| 603 | data-type="my.package.MyFavoriteInterface"/> |
| 604 | </component> |
| 605 | <instance component="...DataEventSubscriber"/> |
| 606 | </ipojo></textarea> |
| 607 | <script class="javascript"> |
| 608 | if(!window.newcodemacro_initialised) |
| 609 | { |
| 610 | window.newcodemacro_initialised = true; |
| 611 | window.oldonloadmethod = window.onload; |
| 612 | window.onload = function(){ |
| 613 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 614 | if(window.oldonloadmethod) |
| 615 | { |
| 616 | window.oldonloadmethod(); |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | </script> |
| 622 | </div> |
| 623 | |
| 624 | <div class="code"> |
| 625 | <div class="dp-highlighter"><table class="dp-c" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="keyword">import</span><span> my.</span><span class="keyword">package</span><span>.MyFavoriteInterface; </span></td></tr><tr><td class="line2"><span class="comment">//...</span><span> </span></td></tr><tr><td class="line1"><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> DataEventSubscriber ... { </span></td></tr><tr><td class="line2"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> handleData(MyFavoriteInterface o) { </span></td></tr><tr><td class="line1"> <span class="comment">// Object received</span><span> </span></td></tr><tr><td class="line2"> <span class="comment">//...</span><span> </span></td></tr><tr><td class="line1"> } </td></tr><tr><td class="line2">} </td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">import my.package.MyFavoriteInterface; |
| 626 | //... |
| 627 | public class DataEventSubscriber ... { |
| 628 | public void handleData(MyFavoriteInterface o) { |
| 629 | // Object received |
| 630 | //... |
| 631 | } |
| 632 | }</textarea> |
| 633 | <script class="javascript"> |
| 634 | if(!window.newcodemacro_initialised) |
| 635 | { |
| 636 | window.newcodemacro_initialised = true; |
| 637 | window.oldonloadmethod = window.onload; |
| 638 | window.onload = function(){ |
| 639 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 640 | if(window.oldonloadmethod) |
| 641 | { |
| 642 | window.oldonloadmethod(); |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | </script> |
| 648 | </div> |
| 649 | |
| 650 | |
| 651 | <h3><a name="EventAdminHandlers-Noteonsynchronouseventsending"></a>Note on synchronous event sending</h3> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 652 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 653 | <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> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 654 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 655 | <p>The behaviour of synchronous event sending is particular when you |
| 656 | specify several topics in the publisher description. The event is |
| 657 | synchronously sent to each topic, one by one. So when you return from |
| 658 | this function, you can be sure that the event has been delivered to |
| 659 | each topic.</p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 660 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 661 | <h3><a name="EventAdminHandlers-Publisherinstanceinformation"></a>Publisher instance information</h3> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 662 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 663 | <p>All events sent by a publisher contains the name of the component |
| 664 | instance that sent them. Its enables to filter received events |
| 665 | depending the sender instance. The instance name is accessible in the |
| 666 | 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> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 667 | |
| 668 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 669 | <h3><a name="EventAdminHandlers-Configuringthehandlerwithannotations"></a>Configuring the handler with annotations</h3> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 670 | |
| 671 | <p>It is possible to configure the handler with a simple annotations |
| 672 | available in the annotation pack ('annotation' project in the iPOJO |
| 673 | trunk). Here is an example of usage:</p> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 674 | <div class="code"> |
| 675 | <div class="dp-highlighter"><table class="dp-c" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="keyword">import</span><span> org.apache.felix.ipojo.annotations.Component; </span></td></tr><tr><td class="line2"><span class="keyword">import</span><span> org.apache.felix.ipojo.handlers.event.Subscriber; </span></td></tr><tr><td class="line1"><span class="keyword">import</span><span> org.osgi.service.event.Event; </span></td></tr><tr><td class="line2"><span class="preprocessor"></span></td></tr><tr><td class="line1"><span class="preprocessor"></span></td></tr><tr><td class="line2"><span class="preprocessor">@Component</span><span> </span></td></tr><tr><td class="line1"><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> PubSub { </span></td></tr><tr><td class="line2"><span class="preprocessor"> @org.apache.felix.ipojo.handlers.event.Publisher(name="p1", synchronous=true)</span><span> </span></td></tr><tr><td class="line1"> org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher1; </td></tr><tr><td class="line2"><span class="preprocessor"> </span></td></tr><tr><td class="line1"><span class="preprocessor"> @org.apache.felix.ipojo.handlers.event.Publisher(name="p2", synchronous=false, topics="foo,bar", data_key="data")</span><span> </span></td></tr><tr><td class="line2"> org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher2; </td></tr><tr><td class="line1"><span class="preprocessor"> </span></td></tr><tr><td class="line2"><span class="preprocessor"> @org.apache.felix.ipojo.handlers.event.Publisher(name="p3", synchronous=true, topics="bar")</span><span> </span></td></tr><tr><td class="line1"> org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher3; </td></tr><tr><td class="line2"><span class="preprocessor"> </span></td></tr><tr><td class="line1"><span class="preprocessor"> @Subscriber(name="s1", data_key="data")</span><span> </span></td></tr><tr><td class="line2"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> receive1(Object foo) { </span></td></tr><tr><td class="line1"> <span class="comment">// Process event</span><span> </span></td></tr><tr><td class="line2"> } </td></tr><tr><td class="line1"><span class="preprocessor"> </span></td></tr><tr><td class="line2"><span class="preprocessor"> @Subscriber(name="s2", topics="foo,bar", filter="(foo=true)")</span><span> </span></td></tr><tr><td class="line1"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> receive2(Event foo) { </span></td></tr><tr><td class="line2"> <span class="comment">// Process event</span><span> </span></td></tr><tr><td class="line1"> } </td></tr><tr><td class="line2"><span class="preprocessor"> </span></td></tr><tr><td class="line1"><span class="preprocessor"> </span></td></tr><tr><td class="line2"><span class="preprocessor"> @Subscriber(name="s3", topics="foo", data_key="data", data_type="java.lang.String")</span><span> </span></td></tr><tr><td class="line1"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> receive3(String foo) { </span></td></tr><tr><td class="line2"> <span class="comment">// Process event</span><span> </span></td></tr><tr><td class="line1"> } </td></tr><tr><td class="line2">} </td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">import org.apache.felix.ipojo.annotations.Component; |
| 676 | import org.apache.felix.ipojo.handlers.event.Subscriber; |
| 677 | import org.osgi.service.event.Event; |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 678 | |
| 679 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 680 | @Component |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 681 | public class PubSub { |
| 682 | @org.apache.felix.ipojo.handlers.event.Publisher(name="p1", synchronous=true) |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 683 | org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher1; |
| 684 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 685 | @org.apache.felix.ipojo.handlers.event.Publisher(name="p2", synchronous=false, topics="foo,bar", data_key="data") |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 686 | org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher2; |
| 687 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 688 | @org.apache.felix.ipojo.handlers.event.Publisher(name="p3", synchronous=true, topics="bar") |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 689 | org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher3; |
| 690 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 691 | @Subscriber(name="s1", data_key="data") |
| 692 | public void receive1(Object foo) { |
| 693 | // Process event |
| 694 | } |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 695 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 696 | @Subscriber(name="s2", topics="foo,bar", filter="(foo=true)") |
| 697 | public void receive2(Event foo) { |
| 698 | // Process event |
| 699 | } |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 700 | |
| 701 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 702 | @Subscriber(name="s3", topics="foo", data_key="data", data_type="java.lang.String") |
| 703 | public void receive3(String foo) { |
| 704 | // Process event |
| 705 | } |
| 706 | }</textarea> |
| 707 | <script class="javascript"> |
| 708 | if(!window.newcodemacro_initialised) |
| 709 | { |
| 710 | window.newcodemacro_initialised = true; |
| 711 | window.oldonloadmethod = window.onload; |
| 712 | window.onload = function(){ |
| 713 | dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| 714 | if(window.oldonloadmethod) |
| 715 | { |
| 716 | window.oldonloadmethod(); |
| 717 | } |
| 718 | } |
| 719 | } |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 720 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 721 | </script> |
| 722 | </div> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 723 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 724 | <p><br clear="all"></p> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 725 | |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 726 | </div> |
| 727 | <img src="event-admin-handlers_files/footer.png" class="footer"> |
| 728 | </div> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 729 | |
| 730 | <script type="text/javascript"> |
| 731 | var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); |
| 732 | document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); |
| 733 | </script><script src="event-admin-handlers_files/ga.js" type="text/javascript"></script> |
| 734 | <script type="text/javascript"> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 735 | try{ |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 736 | var pageTracker = _gat._getTracker("UA-1518442-4"); |
| 737 | pageTracker._trackPageview(); |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 738 | } catch(err) {} |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 739 | </script> |
Clement Escoffier | 580d190 | 2009-07-21 12:06:46 +0000 | [diff] [blame^] | 740 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame] | 741 | </div> |
| 742 | </body></html> |