Java Reference
In-Depth Information
the package, there's not a lot it can do! Fortunately, bnd does offer a way for you to
provide this information by including one or more JAR s on the classpath. Extend your
command further to add the fancyfoods API JAR to the bnd classpath using the
-classpath argument, as follows:
java -jar /biz.aQute.bnd.jar wrap -properties
fancyfoods.department.chocolate.bnd
-classpath fancyfoods.api_1.0.0.jar
fancyfoods.department.chocolate_1.0.0.jar
The resulting manifest file is now nearly as good as it was to start with, as shown in the
following listing.
Listing 12.3
A well-generated bnd manifest
Manifest-Version: 1
Bnd-LastModified: 1309685933015
Bundle-Blueprint: OSGI-INF/blueprint/*.xml
Bundle-ManifestVersion: 2
Bundle-Name: Fancy Foods Chocolate Bundle
Bundle-SymbolicName: fancyfoods.department.chocolate
Bundle-Version: 1.0.0
Created-By: 1.6.0 (IBM Corporation)
Import-Package: fancyfoods.food;version="[1.0,2)",fancyfoods.offers;vers
ion="[1.0,2)"
Private-Package: fancyfoods.chocolate
Tool: Bnd-1.44.0
To the untrained eye the manifest is now done, but if you look more closely you'll see
that the version ranges on the Import-Package statements aren't right. The code in
your bundle doesn't only consume the packages it imports, it implements API from
them as an API provider. This means that a minor version increment would still be
considered a breaking change. Bnd doesn't cope well with this scenario because there
isn't enough information in the Java class files to tell bnd whether the interfaces are
implemented by the consumer or the provider. What you can do is alter your configu-
ration file to let bnd know that you provide implementations for the packages you
import by using the provide directive with a value of true , as follows:
Bundle-Name: Fancy Foods Chocolate Bundle
Bundle-SymbolicName: fancyfoods.department.chocolate
Bundle-Version: 1.0.0
Private-Package: fancyfoods.chocolate
Export-Package:
Import-Package: *; provide:=true
Running with this updated configuration, you finally get back a correctly modularized
manifest, as in the following listing.
Listing 12.4
A completely configured bnd manifest
Manifest-Version: 1
Bnd-LastModified: 1309804592021
Bundle-Blueprint: OSGI-INF/blueprint/*.xml
 
Search WWH ::




Custom Search