Java Reference
In-Depth Information
B
fancyfoods.split.Foo.class
Require-Bundle: C
A
Import-Package:
fancyfoods.split
C
fancyfoods.split.Bar.class
Figure 5.5 In this case, the importing bundle, A, must wire to bundle B's package because the mandatory
directive on bundle C's package requires that the importer specify partial="true" to wire to it. B
uses Require-Bundle: C to unify the package, meaning that both fancyfoods.split.Foo and
fancyfoods.split.Bar are visible to bundle A.
WARNING: Require-Bundle AND ECLIPSE PLUG-IN DEVELOPMENT If you're
using Eclipse's Plugin Development Environment (PDE) to write your bundles,
you may find you're using Require-Bundle instead of Import-Packages even
if you don't have split packages. Historically, Eclipse used Require-Bundle
internally, and its manifest editor occasionally defaults to requiring bundles
rather than importing packages.
For those of you who develop in the Eclipse foundation, you're likely to see split pack-
ages. The reason for the split packages in Eclipse is architectural. The core Eclipse
runtime is packaged as an OSG i bundle and is extended by other bundles that add
extra classes to core packages. Clearly, if the core runtime is going to be extensible, it
can't be tied to all the possible extensions by Require-Bundle . This left Eclipse with a
solution similar to the one that we outlined earlier. Extensions to the Eclipse runtime
bundle use Require-Bundle to unify the split package, and also export the package
with an attribute that marks the extended view of the package. Clients that need a par-
ticular extension then supply a matching attribute on their import and find all the
classes they need. Although this may sound elegant, it does mean that no client can
make use of two extensions at once in a reliable way, and that clients need to be extra
careful about what they import. As before, we strongly discourage you from splitting
packages across bundles that you write.
So far we've been focusing on package imports and exports, but equally important
is what you don't share with the outside world.
Search WWH ::




Custom Search