LuciadLightspeed is compatible with the OSGi framework. The OSGi framework is a module system and service platform for the Java programming language. The Eclipse Rich Client Platform, for instance, uses it as its module system. This means that you can use LuciadLightspeed in applications which are based on the Eclipse Rich Client Platform , for instance.
For more information about OSGi , see http://www.osgi.org.
To use the LuciadLightspeed OSGi bundles in Eclipse, you need to add the Eclipse Plug-in Development Environment software to your Eclipse installation.
Before you can use LuciadLightspeed within an OSGi framework, you must create the necessary OSGi bundles for LuciadLightspeed
. These are JAR files with additional, OSGi -specific manifest headers.
To create the bundles, run the
make_osgi_bundles script in the
build/osgi directory of your LuciadLightspeed installation.
The script creates the OSGi bundles in the
distrib/osgi directory. You can add these bundles to your OSGi framework. In Eclipse, for instance, you can do this by editing the target
platform. Click the
Add button in the Window → Preferences → Plug-in Development → Target Platform window and add the
distrib/osgi directory to the target platform.
make_osgi_bundles script runs a Java application to make the OSGi bundles. The source files for the Java application are available in the
src directory in the
build/osgi directory. This way you can inspect and, if required, modify the way the script works.
build/osgi directory also contains the directory
com.luciad.osgi.sample. This directory contains a sample bundle that demonstrates how to develop applications based on OSGi and LuciadLightspeed
The sample is similar to the
lightspeed.fundamentals.step1 sample. The difference is that it is now delivered as an OSGi bundle. It includes the required information in the
The LuciadLightspeed packages used by the sample are specified in the
The Activator of the bundle is specified in the
Bundle-Activatorheader. The activator is responsible for actually starting the sample.
To start the sample, run the
start_felix script in the
distrib directory. This script starts the Apache Felix OSGi runtime. The runtime is configured to load the LuciadLightspeed OSGi
bundles and start the sample.
The sample directory is also a full Eclipse project. You can import it into Eclipse as an Existing Project, using Eclipse’s File → Import…​ menu item.
You can run the sample by creating a run configuration of the 'OSGi Framework' category. To run the sample without Eclipse-specific errors, you need to disable and enable specific plug-ins in the 'Bundles' tab of the run configuration.
To enable the appropriate plug-ins in the run configuration:
In the 'Bundles' tab, click 'Deselect All'.
Enable the 'com.luciad.osgi.sample' bundle in the 'Workspace' node in the list of bundles.
Click the 'Add Required Bundles' button.
Enable the 'org.eclipse.equinox.console' bundle.
Enable all bundles starting with 'org.apache.felix.gogo'.
make_osgi_bundles script converts all regular LuciadLightspeed jars to OSGi Fragments of the
com.luciad.osgi bundle. All OSGi Fragments logically become a part of their host bundle. This means that they all share the same classloader.
LuciadLightspeed uses this approach because it was not built from the ground up with OSGi in mind.
make_osgi_bundles script also creates a
thirdparty bundle, which contains all the third-party libraries used by LuciadLightspeed . The fragments use the
Require-Bundle OSGi header to import the classes from these libraries. LuciadLightspeed uses this approach because not all third-party dependencies
work well in the alternative setup, in which each library is a bundle on its own.
For the same reasons, the bundles created by the
make_osgi_bundles script rely on the OSGi boot delegation feature to import the classes from the JRE. You need to configure your OSGi runtime
to allow boot delegation for all classes. The startup script of the OSGi sample shows an example for the Apache Felix runtime.