The extender pattern handlerThe objective of this handler is to simplify the development of extender-based architecture. This architecture-style is based on two different roles:
Using the handlerFirst of all, you need to configure the component type to use the handler such as: <iPOJO xmlns:extender="org.apache.felix.ipojo.extender"> <Component className="org.apache.felix.ipojo.extender.myextender"> <!—Extender Pattern handler configuration --> <extender:extender extension="My-Extension" onArrival="onBundleArrival" onDeparture="onBundleDeparture" /> <callback transition="invalidate" method="stopping" /> <callback transition="validate" method="starting" /> <provides /> </Component> </iPOJO> Notice that, this handler is an external handler. So, it uses the "org.apache.felix.ipojo.extender" namespace. void onBundleArrival(Bundle bundle, String header) { // Do something } void onBundleDeparture(Bundle bundle) { // Do something } Notice the different signatures of the methods. The arrival method is called with the arriving bundle and the matching header value (i.e. the value of the My-Extension header of the bundle manifest). The departure method just receives the leaving bundle. ConfigurationThe handler has only three mandatory attributes:
DownloadThe handler is available on the download page. 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.Bundle; @Component @org.apache.felix.ipojo.extender.Extender(extension="foo", onArrival="onArrival", onDeparture="onDeparture") public class Extender { public void onArrival(Bundle bundle, String foo) { // do something } public void onDeparture(Bundle bundle) { // do something } } The extension attribute allows setting the bundle filter. A more realistic exampleThe Junit4OSGi framework, available here , uses this handler to track Junit Test Suite offered by the installed bundles. The Junit4Osgi bundle has a component using this handler to be notified when a bundle with the "Test-Suite" header appears or leaves. |
OverviewGetting Started
User GuideToolsDeveloper Guide
Misc & Contact
|