The bundle
element serves as the root element of the bundle descriptor. It contains the actual meta-information for the bundle. This includes:
Entry |
Bundle descriptor |
Manifest |
---|---|---|
the bundle name |
Bundle-Name |
|
the bundle description |
Bundle-Description |
|
the bundle's symbolic name |
symbolic-name |
Bundle-SymbolicName |
the bundle category |
Bundle-Category |
You'll note the absence of an element for the version number. The Bundle-Version
is usually expected to be set
within the Apache Ant build script as part of a manifest attribute.
The headers
element allows to directly specify a number of manifest headers.
It is theoretically possible to generate, for example, the Bundle-SymbolicName
header here, but there
is no guarantee which value will prevail if it collides with the symbolic-name
element from above.
The headers
element takes one or more header
elements.
Each element takes a mandatory name
attribute. The text value is provided as the element's content.
Example 2.1. Header example
<bundle xmlns="http://www.jeremias-maerki.ch/ns/osgi-bundle"> [..] <headers> <header name="Bundle-Activator">ch.jm.fop.osgi.Activator</header> <header name="Bundle-Vendor">Jeremias Märki</header> <header name="Service-Component">OSGI-INF/configurator.xml</header> </headers> [..] </bundle>
The exports
element allows to directly specify a number of packages to be exported.
The exports
element takes one or more export
elements.
The package name is provided as the element's content. To export a package including all subpackages, you may use a "*" as a wildcard.
Each export
element takes an optional version
attribute to override the version specified by the Bundle-Version
header. If the version
attribute is absent, each package export will
have the bundle's version added as the exported version. All exported bundles will also automatically be imported with the same version number.
This is in line with OSGi best practice.
Example 2.2. Export example
<bundle xmlns="http://www.jeremias-maerki.ch/ns/osgi-bundle"> [..] <exports> <export>org.apache.fop*</export> <!-- ...or ... --> <export>ch.jm.lpr</export> <export>ch.jm.lpr.client</export> </exports> [..] </bundle>
The imports
element allows to directly specify a number of packages to be imported. Normally, the bundle utility will automatically determine all
required imports through byte code analysis but sometimes it's necessary to add directives or
attributes to the import, for example, if you need optional resolution for some packages.
The imports
element takes one or more import
elements.
The package name is provided in the required match
attribute.
To match multiple packages at one you may use "*" as a wildcard. The directives an attributes will then be applied to all these matching packages.
Normally, only imports that have been identified by byte code analysis are matched with the above mechanism. If you want to explicitely import a package,
you can use the add
attribute. The datatype here is
xsd:boolean
and the default is false
for this attribute. The wildcard ("*") is not allowed if add="true"
.
Example 2.3. Import example
<bundle xmlns="http://www.jeremias-maerki.ch/ns/osgi-bundle"> [..] <imports> <import match="org.apache.tools.ant*"> <directive name="resolution">optional</directive> </import> <import match="com.acme.something" add="true"> <attribute name="looney">true</attribute> </import </imports> [..] </bundle>