Java Reference
In-Depth Information
A
B
C
Figure 2.15 Transitive dependencies occur when bundle A depends on packages
from bundle B and bundle B in turn depends on packages from bundle C. To use
bundle A, you need to resolve the dependencies of both bundle B and bundle C.
RESOLVING The process of matching a given bundle's imported packages to
exported packages from other bundles and doing so in a consistent way so
any given bundle only has access to a single version of any type.
Resolving a bundle may cause the framework to resolve other bundles transitively, if
exporting bundles themselves haven't yet been resolved. The resulting set of resolved
bundles are conceptually wired together in such a fashion that any given imported
package from a bundle is wired to a matching exported package from another bun-
dle, where a wire implies having access to the exported package. The final result is a
graph of all bundles wired together, where all imported package dependencies are sat-
isfied. If any dependency can't be satisfied, then the resolve fails, and the instigating
bundle can't be used until its dependencies are satisfied.
This description likely makes you want to ask three questions:
When does the framework resolve a bundle's dependencies?
1
How does the framework gain access to bundles to resolve them in the first
place?
2
What does it mean to wire an importing bundle to an exporting bundle?
3
The first two questions are related, because they both involve the lifecycle layer, which
we'll discuss in the next chapter. For the first question, it's sufficient to say that the
framework resolves a bundle automatically when another bundle attempts to use it. To
answer the second question, we'll say that all bundles must be installed into the frame-
work in order to be resolved (we'll discuss bundle installation in more depth in chap-
ter 3). For the discussion in this section, we'll always be talking about installed
bundles. As for the third question, we won't answer it fully because the technical
details of wiring bundles together isn't important; but for the curious, we'll explain it
briefly before looking into the resolution process in more detail.
At execution time, each OSG i bundle has a class loader associated with it, which is
how the bundle gains access to all the classes to which it should have access (the ones
determined by the resolution process). When an importing bundle is wired to an
exporting bundle, the importing class loader is given a reference to the exporting
class loader so it can delegate requests for classes in the exported package to it. You
don't need to worry about how this happens—relax and let OSG i worry about it for
you. Now, let's look at the resolution process in more detail.
Search WWH ::




Custom Search