Java Reference
In-Depth Information
Listing 7.3
Successfully resolving with a uses clause
Bundle-SymbolicName: Exporter
Export-Package: fancyfoods.special; uses:="fancyfoods.used"
Import-Package: fancyfoods.used; version="[1,2)"
Bundle-SymbolicName: Importer
Import-Package: fancyfoods.special,
fancyfoods.used; version="[1,2)"
In listing 7.3, you can see two bundles. One bundle exports a package, fancy-
foods.special , with a uses constraint of fancyfoods.used . The other bundle
imports the fancyfoods.special and fancyfoods.used packages. The resolver
knows that the importing bundle must be wired to the same instance of fancy-
foods.used that the exporting bundle is, as shown here.
Listing 7.4
Successfully resolving with a uses clause
Bundle-SymbolicName: Exporter
Export-Package: fancyfoods.special; uses:="fancyfoods.used"
Import-Package: fancyfoods.used; version="[1,2)"
Bundle SymbolicName: Importer
Import-Package: fancyfoods.special
In listing 7.4, you can see two bundles similar to those in listing 7.3—one that exports
package fancyfoods.special with a uses constraint of fancyfoods.used , and
another that imports fancyfoods.special but not fancyfoods.used . In this case, the
importing bundle can't see the fancyfoods.used package at all. Because of this, the
importing bundle is class-space compatible with any view of that package. This might
sound odd, but think of it this way: the importing bundle has no way to get the fancy-
foods.used package; therefore it can't have an incompatible view! The end result of
this is that, as in the following listing, we can successfully wire these bundles together.
Listing 7.5
Failure to resolve with a uses clause
Bundle-SymbolicName: Exporter
Export-Package: fancyfoods.special; uses:="fancyfoods.used"
Import-Package: fancyfoods.used; version="[1,2)"
Bundle SymbolicName: Importer
Import-Package: fancyfoods.special,
fancyfoods.used; version="[2,3)"
Listing 7.5 is another variation on listing 7.3. Again, the Exporter hasn't changed, but
the Importer has a different import version range for fancyfoods.used . In this case,
the importing bundle can see the fancyfoods.used package, but can never wire to
the same package that the Exporter bundle does. Because of this, you can guarantee
that the uses constraint on the fancyfoods.special package will never be satisfied.
This means that the resolver can't wire the import and export together, even though
they look like they should match.
 
Search WWH ::




Custom Search