8.1 Creating the Reaction OSGi Bundle

The Reaction OSGi bundle consists of the API package, the core implementation package, the OSGi wrapper package and the utilities package. OSGi bundle creation may be carried out using the bnd bundle creation tool originally written by Peter Kriens[1] using the configuration shown in Listing 8.1. The full version of this configuration file may be found in the root directory of the source code distribution as Reaction.bnd.

% latex2html id marker 2059\begin{small}\begin{verbatim}Bund...
...ator\end{verbatim} \end{small}\caption{Basic OSGi Bundle Metadata}

The bundle configuration specifies that the only exported package is the API package (com.zynaptic.reaction). This provides the only mechanism for accessing the functionality of the Reaction framework from other OSGi bundles. The reactor lifecycle management is now carried out automatically by the bundle activator, which starts the reactor when the bundle is started and shuts it down when the bundle is stopped.

The standard OSGi configuration makes use of the default bundle activator. This uses hardcoded implementations of the monotonic clock source and logging target as described below.

The default bundle activator is applicable to all platforms supported by the OSGi framework and will be a good choice for most applications. However, there are situations where a different choice of monotonic clock source or logging target would be applicable. Creating a modified version of the bundle activator which supports a different combination of monotonic clock source and logging target is simply a matter of changing the MonotonicClockSource and ReactorLogTarget implementation classes. It is good practise to create a new activator class when making such changes, which will result in a corresponding change to the Bundle-Activator descriptor in the bundle metadata.