Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Include Page
FELIX:apache-felix-ipojo-headerFELIX:
apache-felix-ipojo-header

...

The objective of this handler is to simplify the development of extender-based architecture. This architecture-style is based on two different rolesentities:

  • The extender (also called host)
  • The extensions
Div
classtoc
Table of Contents
maxLevel4
minLevel2

...

The Extender pattern

This architecture-style is based on two different roles:

...

First of all, you need to configure the component type to use the handler such as:

Code Block
xml
xml
<iPOJO<ipojo xmlns:extender="org.apache.felix.ipojo.extender">
	<component
		classname="org.apache.felix.ipojo.extender.myextenderMyExtender">
		
                <!-- 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>ipojo>

Notice that, this handler is an external handler. So, it uses the "org.apache.felix.ipojo.extender" namespace.
You can also use annotations:

Code Block

@Component
@Extender(
	onArrival="onBundleArrival",
	onDeparture="onBundleDeparture",
	extension="My-Extension")
public class MyExtender {

	@Validate
	public void starting() {
	  // ...
	}
	
	@Invalidate
	public void stopping {
	  // ...
	}

	void onBundleArrival(Bundle bundle, String header) {
	         // Do something
	}

	void onBundleDeparture(Bundle bundle) {
	        // Do something
	}
}


Once described, you can implement your component. The methods specified methods will be called when a matching bundle arrives or leaves.
In the previous example, these methods could be:

...

The 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.

Include Page
FELIX:apache-felix-ipojo-footerFELIX:
apache-felix-ipojo-footer