The OSGi framework supports deploying bundles into a flat and basically globally bundle space. The idea behind this approach can be summarized as, "the deployed set of bundles is your application configuration." This approach has performed well over the years; however, as OSGi technology is used in more and more complicated scenarios, this approach is not always sufficient. For example, when trying to run multiple applications in a single framework instance or when applications become so large that sets of bundles start mapping onto logical subsystems. In these types of situations, it is possible for the configurations of different applications or subsystems to interfere with each other.
To address some of these issues, this proposal introduces a composite bundle concept built on top of virtual bundles. The main goal of this proposal is to provide an isolation mechanism for groups of bundles, while still allowing collaboration among those groups and to manage everything as a layer above the framework.
Some potential use cases for composite bundles:
This list is not intended to be exhaustive.
The following terms are used in this document:
The overall technical approach is to build a layer on top of the virtual bundle concept (proposed separately) to manage composite as a layer above the framework. The specific approach is to forgo an API-based approach to support a simple, declarative approach. Therefore, the technical approach is actually divided into two halves: composite declaration and composite lifecycle management.
NOTE: The goal is not to completely rule out any API, but to keep things simple until some real-world experience is gained at which point API could potentially be introduced.
A composite bundle is declared using a set of manifest-like headers, which is familiar to bundle developers and fits well with the virtual bundle proposal, where virtual bundles are installed with a given set of headers. Many existing headers are reused to declare a composite bundle, but not all are applicable (e.g., Bundle-ClassPath, Bundle-Activator, Bundle-NativeCode, Bundle-ActivationPolicy). Other than explicitly disallowed headers, all other headers maintain their normal meaning. For example, code dependencies are handled by:
For service dependencies, this proposal resurrects the following headers:
A new header is introduced to declare the composite's constituent bundles:
To simplify matching a composite's exported packages to contained bundles, this proposal introduces a new from directive for Export-Package, which is used to specify the symbolic name of the providing bundle. Consider the following composite declaration:
Bundle-ManifestVersion: 2 Bundle-Name: Full Paint Program Bundle-SymbolicName: composite.example.full Include-Bundle: \ file:/Users/rickhall/Projects/book-trunk/code/chapter04/paint-example/bundles/shape-4.0.jar, \ file:/Users/rickhall/Projects/book-trunk/code/chapter04/paint-example/bundles/paint-4.0.jar, \ file:/Users/rickhall/Projects/book-trunk/code/chapter04/paint-example/bundles/circle-4.0.jar, \ file:/Users/rickhall/Projects/book-trunk/code/chapter04/paint-example/bundles/square-4.0.jar, \ file:/Users/rickhall/Projects/book-trunk/code/chapter04/paint-example/bundles/triangle-4.0.jar Export-Package: org.foo.shape; from:=org.foo.shape; version="4.0" Import-Package: org.osgi.service.log; version=1.0.0 Import-Service: org.foo.shape.SimpleShape |
This composite contains five bundles and exports org.foo.shape from the bundle with the symbolic name org.foo.shape. Further, it also imports the log service package and any services implementing the org.foo.shape.SimpleShape interface from the package it exports.
TBD