The white board pattern handlerThe objective of this handler is to simplify the development of
white-board architecture. This architecture-style is based is very
close to the extender architecture style but use services instead of
bundles.
More information on this pattern is available in this document UPDATE: the 1.1.0-SNAPSHOT has a new namespace org.apache.felix.ipojo.whiteboard instead of org.apache.felix.ipojo.white-board-pattern Using the handlerFirst of all, you need to configure the component type to use the handler such as: <ipojo xmlns:wbp="org.apache.felix.ipojo.whiteboard"> <component className="org.apache.felix.ipojo.test.FooWhiteBoardPattern" > <wbp:wbp filter="(my.property=1)" onArrival="onArrival" onDeparture="onDeparture" onModification="onModification" /> <provides/> </component> Notice that, this handler is an external handler. So, it uses the "org.apache.felix.ipojo.whiteboard" namespace. public class FooWhiteBoardPattern implements Observable { List list = new ArrayList(); int modifications = 0; public synchronized void onArrival(ServiceReference ref) { list.add(ref); } public synchronized void onDeparture(ServiceReference ref) { list.remove(ref); } public synchronized void onModification(ServiceReference ref) { modifications = modifications + 1; } public synchronized Map getObservations() { Map map = new HashMap(); map.put("list", list); map.put("modifications", new Integer(modifications)); return map; } All method received the arriving, leaving or modified service reference. ConfigurationThe handler has only three mandatory attributes:
The onModification attribute is optional. This method is called when an injected service reference is modified but stills valid against the filter.
Configuring the handler with annotations [New in 1.1.0-SNAPSHOT]It is possible to configure the handler with a simple annotation available in the annotation pack ('annotation' project in the iPOJO trunk). Here is an example of usage: import org.apache.felix.ipojo.annotations.Component; import org.osgi.framework.ServiceReference; @Component @org.apache.felix.ipojo.whiteboard.Wbp(filter="(foo=true)", onArrival="onArrival", onDeparture="onDeparture", onModification="onModification") public class WhiteBoardExemple { public void onArrival(ServiceReference ref) { // do something } public void onDeparture(ServiceReference ref) { // do something } public void onModification(ServiceReference ref) { // do something } } The onModification attribute is optional.The filter attribute allows setting the service filter. DownloadThe handler is available on the download page. |
OverviewGetting Started
User Guide
Tools
Developer Guide
Misc & Contact
|