OSGI (ServiceMix) – Fundamentals that You Should Know along with OSGI Singleton

OSGI is a excellent concept that allows multiple different application to be deployed in a single JVM. In an OSGI, each application or unit is called bundle. Each bundle is loaded into the JVM with different class loaders.

Following are major keywords in the OSGI.

  • Bundles – Bundles are the OSGi components made by the developers.
  • Services – The services layer connects bundles in a dynamic way by offering a publish-find-bind model for plain old Java objects.
  • Life-Cycle – The API to install, start, stop, update, and uninstall bundles.
  • Modules – The layer that defines how a bundle can import and export code.
  • Security – The layer that handles the security aspects.
  • Execution Environment – Defines what methods and classes are available in a specific platform.

OSGI is a good operating model if you have a many applications that requires:

  1. applications tightly interacts with each others.
  2. requires low latency in processing – this is achieved in OSGI environment as applications are deployed in same JVM. Though applications are partitioned by class loader, they run on same JVM. Thus, application may interact without leaving the JVM, providing the low latency. Here applications are segregated at development time but tightly coupled at run-time for performance.

Disadvantages of OSGI:

  1. Applications are tightly coupled at run-time environment, even though applications are decoupled through bundle.
  2. Applications shares same JVM resources; thus requires extra analysis before adding an application to ensure that JVM resources are not overly consumed by one application. This gives rise to a possibility of an application using too much resources while starving other application.
  3. A problem application can bring down whole OSGI environment; thus introducing run-time risk associated with other application.
  4. If an OSGI environment needs recycle, this impacts all the application in that environment.
  5. Applications are tightly coupled in OSGI environment, even though they are total different and separate functional processing.

OSGI and Singleton

Singleton by definition is a single class in the JVM.


  1. https://www.osgi.org/developer/architecture/
  2. Redhat Deployment Model