Reactive Blocks has a feature that supports development of OSGi bundles. This article describes this feature from installation step to bundle creation and deployment.
There are a number of OSGi frameworks, for instance:
Bundles created by the Reactive Blocks SDK should run on all of these. In the following, we just pick Equinox to explain how to run an OSGi bundle.
If you have used Reactive Blocks for OSGi feature before, you simply need to update. Do the following steps: (Error markings during the update prosess are OK)
If you have developed OSGi applications with Reactive Blocks before, you may need to rebuild them.
To install the Reactive Blocks for OSGi feature, do the following steps:
We define a set of plug-ins that can be used to build and run OSGi bundles. It contains
Since this definition changes the target platform in your Eclipse workspace, it is advisable to switch to a new workspace.
Before making an OSGi bundle, we first create a Reactive Blocks plug-in project and an application block.
Note that a Plug-in project must contain maximal one application block.
Depending on your application, you might need to import packages from other bundles, like paho for MQTT. Read section About Dependency below to see how to add a bundle as project dependency.
When the build process is completed, you should see a new source folder gen containing generated code from your application.
Depending on your application, the generated code may also need dependency to other packages or bundles. Read section About Dependency below to see how to add a bundle as project dependency.
We provide a launch configuration to run OSGi bundles from within Eclipse.
You should see that the Equinox OSGi framework is running from the Console view.
To stop the OSGi framework, just use the red stop button on the Console view.
You may need to import other packages from external bundles, like paho for MQTT, in your application. Moreover, the generated code may require such dependency.
First, make sure the external bundles are available in your target platform.
Thereafter, you can modify the manifest of the project that contains your application manually.
There are some indications that one or more bundles need to be installed in the OSGi framework:
When launching your OSGi framework, you see similar error message to the following:
org.osgi.framework.BundleException: Could not resolve module: br.mqtt.sender 
The bundle containing your application is not in state active. For the Equinox OSGi framework, you can use commands
diag <bundle-id> as shown in the following figure.
The figure above shows that bundle br.mqtt.sender (bundle id 64) has an unresolved requirement. It needs to import package com.bitreactive.library.mqtt. This package is provided by bundle com.bitreactive.library.mqtt (bundle id 10). However, the provider bundle itself has an unresolved requirement. There is no bundle that can provide package org.eclipse.paho.client.mqttv3.
To solve this problem, you need to find a bundle that exports package org.eclipse.paho.client.mqttv3 and basically install the bundle in the OSGi framework.
If you are using an Eclipse launch configuration (see Run an OSGi Application section), do the following: