A composite bundle groups shared bundles together into aggregates. A composite bundle is described in a composite bundle manifest file, META-INF/COMPOSITEBUNDLE.MF. This manifest file lists the OSGi bundles that are directly contained in the composite bundle, and the reference bundles that are hosted alongside the composite bundle in the same EBA file, or in the same bundle repository.
A composite bundle provides one or more packages at specific versions to an application. Therefore
all the versions in a composite bundle manifest are exact.
Eclipse tools provides convenient editors for the manifest file.
Here is an example composite bundle manifest file,
META-INF/COMPOSITEBUNDLE.MF:
Manifest-Version: 1.0
CompositeBundle-ManifestVersion: 1
Bundle-Name: Blog Application
Bundle-SymbolicName: com.ibm.ws.osgi.example.Blog
Bundle-Version: 1.0
CompositeBundle-Content:
com.ibm.ws.osgi.example.blog;version="[1.0,1.0]",
com.ibm.ws.osgi.example.blog.persistence;version="[1.0,1.0]"
Import-Package: com.ibm.ws.other.pkge;version=1.0.0
Export-Package: com.ibm.ws.osgi.example.blog;version=1.0.0
CompositeBundle-ExportService:
com.ibm.ws.osgi.example.blog.BloggingService;filter="(blog.type=community)"
CompositeBundle-ImportService:
com.ibm.ws.osgi.example.auth.UserAuthService
The metadata
in a composite bundle manifest file includes the following headers:
- Manifest-Version
- A version number for the manifest format.
- CompositeBundle-ManifestVersion
- The composite bundle manifest version to which this manifest conforms.
- Bundle-Name
- A human-readable name of the composite bundle.
If you do not
specify a value, the default value is the composite bundle symbolic
name.
- Bundle-SymbolicName
- A name that identifies the composite bundle uniquely. The name
follows the same scheme as the Bundle-SymbolicName header
in an OSGi bundle. The value must not be the same as the value of
the Bundle-SymbolicName of any of the bundles in the composite bundle,
as listed in the CompositeBundle-Content header.
- Bundle-Version
- A version number that identifies the version of the composite
bundle uniquely.
- CompositeBundle-Content
- A list of bundles in the composite bundle. All bundles must be
available for deployment and must be contained in the .cba file,
or exist in an available bundle repository. Bundles must have exact
version numbers. If you require the same composite bundle with different
versions of its content, you require different versions of the composite
bundle, one version for each usage.
- Import-Package
- A list of packages that the composite bundle wants to import.
This list is developed from the import package lists in the individual
bundle manifests within the composite bundle:
- If an individual bundle manifest specifies an import package,
and the same package is contained in another bundle in the composite
bundle, then the composite bundle need not import the package.
- If a bundle in the composite bundle specifies an import package
that is not otherwise available within the composite bundle, then
the package must be listed as an import package in the composite bundle
manifest.
- Export-Package
- A list of packages that the contents of the composite bundle provides
to the shared bundle space.
Note: A composite bundle can export a package
from a bundle JAR file that is contained in the composite bundle,
provided that package is also listed in the Export-Package header
in the bundle manifest file of the contained bundle. However, the
attributes and directives that are specified for that package in the
Export-Package header of the composite bundle manifest file must exactly match
those specified in the manifest file of the contained bundle, otherwise
the package is not exported.
- CompositeBundle-ExportService
- A list of service interface names and optional filters that identify
services that are present in the composite bundle and that can be
exported for use outside the composite bundle. The interfaces that
an exported service implements are usable outside the composite bundle
if those interfaces are visible outside the composite bundle.
The
format is a comma-separated list of services, in the form of a service
interface name, followed by attributes or directives. The
CompositeBundle-ExportService header
has the following attribute:
- filter
- An OSGi service filter.
- CompositeBundle-ImportService
- A list of service interface names and optional filters that identify
services that the contents of the composite bundle want to use from
outside the composite bundle. At least one such service must exist
at run time.
The format is a comma-separated list of services, in
the form of a service interface name, followed by attributes or directives.
The
CompositeBundle-ImportService header has the
following attribute:
- filter
- An OSGi service filter.