An OSGi bundle, which can be a JAR or web application archive
(WAR) file, contains a bundle manifest file. The bundle manifest file
contains additional headers to those in the manifest for a JAR or
WAR file that is not an OSGi bundle. The metadata that is specified
in these headers enables the OSGi Framework to process the modular
aspects of the bundle.
The following shows an example bundle manifest file,
META-INF/MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyService bundle
Bundle-SymbolicName: com.sample.myservice
Bundle-Version: 1.0.0
Bundle-Activator: com.sample.myservice.Activator
Import-Package: org.apache.commons.logging;version="1.0.4"
Export-Package: com.sample.myservice.api;version="1.0.0"
The
metadata in a bundle manifest file includes the following key headers:
- Bundle-Version
- Describes the version of the bundle, and enables multiple versions
of a bundle to be active concurrently in the same framework instance.
- Bundle-Activator
- Notifies the bundle of lifecycle changes.
- Import-Package
- Declares the external dependencies of the bundle that the OSGi
Framework uses to resolve the bundle. Specific versions or version
ranges for each package can be declared. In this example manifest
file, the org.apache.commons.logging package is
required at Version 1.0.4 or later.
- Export-Package
- Declares the packages that are visible outside the bundle. If
a package is not declared in this header, it is visible only within
the bundle.
Eclipse tooling provides convenient editors for the
bundle manifest file.