Java Reference
In-Depth Information
At first blush, resolving dependencies is fairly straightforward; the framework just
needs to match exports to imports. Let's consider a snippet from the paint program
Bundle-Name: Simple Paint Program
From this, you know that the paint program has a single dependency on the package. If only this bundle were installed in the framework, it
wouldn't be usable, because its dependency wouldn't be satisfiable. To use the paint
program bundle, you must install the shape API bundle, which contains the follow-
ing metadata:
Bundle-Name: Paint API
When the framework tries to resolve the paint program bundle, it knows it must find a
matching export for . In this case, it finds a candidate in the shape API
bundle. When the framework finds a matching candidate, it must determine whether
the candidate is resolved. If the candidate is already resolved, the candidate can be
chosen to satisfy the dependency. If the candidate isn't yet resolved, the framework
must resolve it first before it can select it; this is the transitive nature of resolving
dependencies. If the shape API bundle has no dependencies, it can always be success-
fully resolved. But you know from the example that it does have some dependencies,
namely javax.swing :
Bundle-Name: Paint API
Import-Package: javax.swing
What happens when the framework tries to resolve the paint program? By default, in
OSG i it wouldn't succeed, which means the paint program can't be used. Why?
Because even though the package from the API bundle satisfies the
main program's import, there's no bundle to satisfy the shape API 's import of
javax.swing . In general, to resolve this situation, you can conceptually install another
bundle exporting the required package:
Bundle-Name: Swing
Export-Package: javax.swing
Now, when the framework tries to resolve the paint program, it succeeds. The main
paint program bundle's dependency is satisfied by the shape API bundle, and its
dependency is satisfied by the Swing bundle, which has no dependencies. After resolv-
ing the main paint program bundle, all three bundles are marked as resolved, and the
framework won't try to resolve them again (until certain conditions require it, as we'll
describe in the next chapter). The framework ends up wiring the bundles together, as
shown in figure 2.16.
Search WWH ::

Custom Search