Java Reference
In-Depth Information
As with bnd, Bundlor creates a manifest for the JAR file, but the default output is to
System.out . This isn't the most useful location for wrapping bundles, but it's easy to
get Bundlor to package the manifest back into a JAR file using the -o property to spec-
ify an output file, as follows:
bundlor.bat -i ..\jars\fancyfoods.department.chocolate_1.0.0.jar
-o ..\out\fancyfoods.chocolate.bundled.jar
The manifest file in the bundle created by Bundlor is a little different from the one
created by bnd, as shown next.
Listing 12.5
A default manifest from Bundlor
Manifest-Version: 1.0
Bundle-Blueprint: OSGI-INF/blueprint/*.xml
Bundle-SymbolicName: fancyfoods.department.chocolate
Tool: Bundlor 1.0.0.RELEASE
Export-Package: fancyfoods.chocolate;uses:=",fancyfoods
Bundle-Version: 1.0.0
Bundle-ManifestVersion: 2
The default manifest that comes out of Bundlor is stricter than the one that came out
of bnd. Note that none of the imports are optional, and that only the package contain-
ing code is exported. Other than this, though, there isn't much difference between
the Bundlor output and the first bundle you generated with bnd. Neither has version-
ing, and neither has any concept of private implementation. Bundlor wouldn't be of
much use if these generated manifests couldn't be refined in some way, and they can
through the use of template manifests.
Template manifests in Bundlor are similar to bnd configuration files. Any headers
specified in the template are copied into the generated manifest, and some special
header values are used as processing instructions to guide generation. Given that
Bundlor does a better job of defaulting the bundle's symbolic name and version, you
can avoid specifying them (though, in general, specifying them is a good idea). What
you do need to do is to tell Bundlor about your private packages and the versions of
your imports.
In Bundlor, packages can be marked as private using the Excluded-Exports
header in the template manifest; in this case you need to exclude the fancy-
foods.chocolate package. Adding version ranges to your package imports also
requires a modification to the template manifest. In this case, you need to add an
Import-Template header. The Import-Template header allows you to provide attri-
butes for selected package imports, using * as a wildcard if necessary. The resulting
template manifest should end up looking something like the following listing.
Listing 12.6
A template manifest for use with Bundlor
Excluded-Exports: fancyfoods.chocolate
Import-Template: fancyfoods.*;version="[1.0,1.1)"
Search WWH ::

Custom Search