Introduction to OSGi

The OSGi Alliance (Open Services Gateway initiative) provides hardware-independent specifications for component- and service-based software platforms. Originally, these specifications were designed to run in Java Virtual Machines. map.apps uses this specification and implements core parts of it using JavaScript to provide a modular and service-based framework to develop dynamic web map applications.

“Services” in the sense of OSGi does not mean “web services”. Instead it means that an object with a set of properties is registered in an OSGi Runtime. The term for “Module” in OSGi is "Bundle". Both are synonyms for the same concept.

OSGi is adopted for JavaScript because of the following facts:

  • Clean and modular programing model

  • High potential for reuse of created modules

  • Independent versioning of modules

  • It defines a dynamic service layer over which the modules communicate.

  • It is designed for runtime changes:

    • Installation, updates, removal of modules during runtime

    • Registration/unregistration of services during runtime

The JavaScript OSGi Runtime adopts the following OSGi Specifications:

  • OSGi Core Specifications

    • Module Layer (partial)

    • Module Lifecycle Layer

    • Service Layer

    • Start Level Service Specification

  • OSGi Compendium Specifications

    • Declarative Services Specification

    • Event Admin Service Specification

    • Log Service Specification

    • User Admin Service Specification

    • Configuration Admin Service Specification

    • Metatype Service Specification (only prepared)

On the following pages, some core principles of OSGi and its adoption in JavaScript are explained. For in-depth understanding of the next sections, we recommend to read the OSGi specifications or one of the OSGi books.

map.apps OSGi Runtime

The JavaScript (JS) OSGi runtime is running completely within the browser of the user. The ArcGIS API for JavaScript and the Dojo JavaScript Toolkit are used as base APIs. Components in the app can communicate with different backend systems, for example ArcGIS for Server, to execute different tasks.

map.apps is shipped with a backend server, which provides special performance enhancements and functionality, such as the app and app-template storage system. Nevertheless, this is fully optional and the JS OSGi runtime is independent of it.

Within the JS OSGi runtime, custom code is structured in modules. In OSGi terms, a module is called 'bundle'. Bundles might depend on other bundles and together they define the behavior of the app.

On an abstract level, each JS OSGi app consists of the following architectural layers:

runtime architecture

  • Module Layer: Defines how a bundle is structured and how it is resolved.

  • Module Lifecycle: Defines how bundles can be installed in the JS OSGi runtime and which lifecycle states they have.

  • Dynamic Service Layer: Defines how bundles can register/unregister/resolve services (logical components) in the JS OSGi runtime.

  • Declarative Components: Defines how services can be declared declaratively within bundles.

  • Configuration: Defines how the configuration process works and how it can be used to change configuration properties at runtime.

  • App Infrastructure Modules: Defines the current base bundles needed to run an app in the browser.

On the next pages each of these layers is described in more detail.