OSGi application isolation and sharing

At run time, OSGi applications are isolated from each other, but their dependencies are shared.

In the runtime environment, OSGi applications are isolated from each other:
  • OSGi applications cannot share packages.
  • Each OSGi application runs in its own isolated OSGi framework with its own service registry.
  • OSGi services can be imported and exported between frameworks by setting the appropriate headers in the application manifest.

For each application server that is running one or more OSGi applications, there is also one shared bundle space.

The primary content of an OSGi application runs in the framework of the application. The dependency bundles and the shared bundles in the application run in the shared bundle space.

When an application is started, the bundles that are listed in the deployment manifest of the application are loaded into the runtime environment. The bundles that are listed in the Deployed-Content header in the deployment manifest are loaded into the isolated framework. The bundles that are listed in the Deployed-Use-Bundle and the Provision-Bundle headers in the deployment manifest are loaded into the shared bundle space.

The dependency bundles in the shared bundle space can originate from the internal bundle repository, the external bundle repository, or the content of the application.

However, shared bundles in an application must be provided by reference rather than contained directly in an application. This is because if shared bundles are contained directly in an application, they are not available to other applications when the applications resolve, but are in the shared bundle space at run time, which might cause problems.

The following shows an example application manifest:
Manifest-Version: 1.0
Application-ManifestVersion: 1.0
Application-Name: Example Blog
Application-SymbolicName: example.blog.app
Application-Version: 1.0
Application-Content:
 example.blog.api;version=”[1.0.0,2.0.0)”, 
 example.blog;version=”[1.0.0,2.0.0)”

When dependencies are resolved, the deployed application needs to pull in an additional dependency bundle blog.required.bundle at version 1.2.0. This bundle is available in package blog.required.package. This package is connected from the dependency bundle in the shared bundle space to bundles in both isolated application frameworks, as shown in the following diagram.

Figure 1. Application frameworks and the shared bundle space
Image is described in accompanying text