Skip to content

Brief tour of OSGi Changes in BUG Linux Release 3.0

kgilmer edited this page Aug 12, 2011 · 5 revisions

Brief tour of OSGi Changes in BUG Linux Release 3.0

This page walks a BUG user through the changes from BUG SW Release 2.1 to 3.0. A large refactoring effort was realized in this release that requires some explanation.

New Felix Launcher

The standard Felix launcher is a general purpose launcher that is not necessarily designed for embedded use on a device like BUG. Specifically:

  • No easy way of partitioning configuration data
  • Log Service not available in early part of framework start
  • Difficult to add bundles dynamically
  • Bundle cache presents problems when users want to update bundles
  • Custom shell environment for bundle and framework management
  • Launch configuration metadata difficult to edit and read

In order to address these concerns, a new launcher was written, knapsack. The basic premise of knapsack is to use the filesystem and native shell environment as the user interface into the OSGi runtime environment.

Primary points that should be known:

  • BUG OSGi runtime environment has moved from /usr/share/java/ to /usr/share/osgi.
  • Application bundles are now stored in /usr/share/osgi/apps.
  • Users can interact with the running OSGi runtime by running the commands available in /usr/share/osgi/bin. For example, to see what services are available, from an ssh session on BUG, run /usr/share/osgi/bin/services.
  • The old OSGi socket-based shell environment is no longer running.

It is important to note that these changes are only as part of the launcher, and the core R4.2 OSGi framework remains vanilla Felix.

Bundle Changes

Determining how code should be organized into modules is an art, and as such is difficult to get right. Since the initial BUG SW release many years ago, it was better to just leave things as is instead of making them better. Part of the refactoring effort was to make big changes at one time to make the BUG modularity such that modules can be effectivly added and removed based on software and hardware requirements. For example, if a given instance will not use web services, the com.buglabs.bug.ws bundle can be removed and the web services will not be executed. The same goes for BMI, specific modules, and the BUG Base 2.0 hardware features.

com.buglabs.bug.program, com.buglabs.bug.services, com.buglabs.bug.module have been combined into com.buglabs.bug.ws.

API Changes

ServiceTracker

In order to break with many successive versions of subly broken ServiceTracker abstractions, the package namespace com.buglabs.application has been deprecated and valid ServiceTracker abstractions are now in com.buglabs.util.osgi. Consolidation and simplification have resulted in one primary class, ServiceTrackerUtil that with static methods allows for the easy tracking of OSGi services.

The Java 6 varargs feature allows for a simple API like

ServiceTrackerUtil.openServiceTracker(
    bundleContext, myApplication, HttpService.class.getName(), MyService.class.getName);

That is, services can simply be appended in the method to be added to the tracker. Additionaly ServiceFilterGenerator has become FilterUtil and joined ServiceTrackerUtil in the com.buglabs.util.osgi package namespace.

XML

The BUG XML API has had some minor change. Most notably, SelfReferenceException has been removed and the API now is clean of checked exceptions. This makes for cleaner coding, and in the case of an invalid XML composition in code, an unchecked exception will be thrown.

Additionally the parsing and serialization backend for the XML library has been migrated the the XPP3 library. This results in faster and cleaner XML support while using a well tested XML library.

BUG 1.x APIs

All APIs related to BUG 1.X hardware features (menu, statusbar, buttons) have been removed. The 2.0 Button API has been moved to the com.buglabs.bug.buttons package namespace.

SDK Changes

Given apparent lack of use, lack of time to maintain and improve upon them, the SDK C/C++ and Target Device Manager plugins have been removed. The BUG Simulator now uses knapsack under the hood to launch Felix and the BUG bundles.