Jahia OSGi architecture

  Written by The Jahia Team
 
Developers
   Estimated reading time:

This topic presents a high-level views of the architecture, flows, and class loader hierarchies of Jahia OSGi integration.

Architecture overview

Jahia has integrated an OSGi runtime framework developed by the Apache Foundation called Apache Karaf. Apache Karaf actually uses the Apache Felix OSGi implementation and also provides out-of-the-box tooling such as an SSH Command Line interface and clustering support (Apache Karaf Cellar), which the basic Apache Felix implementation lacks. With these integrations, module developers benefit from the clean isolation and highly dynamic deployments that this technology offers.

osgi-module-development-architecture-overview.png

Inside the OSGi framework,  all the OSGi bundles are managed by Apache Karaf which brings functionality such as support for module management in clusters. Other system bundles include the Apache Felix OSGi Web Console and the Apache Karaf SSH Command Line shell, which are two low-level administration tools that are quite useful for accessing the OSGi internal runtime.

The Jahia administration is implemented using OSGi modules and therefore now also lives inside the OSGi framework.

Request flow

The request flow was modified with the introduction of the OSGi framework to address the following requirements. Be able to:

  • serve resources directly from an OSGi bundle, compile JSPs that are located inside bundles, and serve images directly from the JAR
  • integrate other OSGi Http services such as the OSGi Web console or custom servlets packaged inside Jahia modules

The diagram below shows how the different software components interact in request processing.

  • The left side reflects the legacy request flow processing before OSGi introduction.
  • In the middle, an Http Bridge (Apache Felix Http Bridge) relays the requests through the OSGi Http service to integrate with bundles that register servlets inside the Http Service. The Jahia OSGi extender is a bundle that listens to bundle events and is responsible for registering all the different resources of a bundle into the Http Service.
  • On the right, Jahia also exposes another OSGi proxy servlet to expose services such as the Apache Felix OSGi Web Console available at the Jahia http://localhost:8080/tools URL.

Class loader graph

This section illustrates what the class-loading graph looks like in a typical Jahia installation. By default, the server is integrated with the Apache Tomcat servlet container, and the diagram below includes the Tomcat class loaders.

As you can see, the Jahia Webapp is the main application class loader, but below that the diagram no longer looks like a tree as OSGI class loaders may access different class loaders depending on their declared dependencies.

If you’re interested in learning more about the Tomcat class loader, you can find the related Tomcat documentation here.