Java Reference
In-Depth Information
define the filter used for matching capabilities. The attributes for a capability
must contain an entry whose key matches the capability's namespace.
A set of directives that are used to provide instructions to the matching algo-
rithm, or to the OSG i runtime.
For OSG i bundles, there are standard mappings for the specification-defined capabil-
ities and requirements. Headers such as Import-Package , Require-Bundle , and
Fragment-Host correspond to requirements, whereas Export-Package and the exis-
tence of the bundle are capabilities.
The bundle capabilities
Aside from the packages it exposes, a bundle still has other capabilities, though you
probably wouldn't think of them that way normally. These are the capability to be
required by another bundle using Require-Bundle , and the capability to host a frag-
ment when specified by Fragment-Host . These capabilities both loosely correspond
to the Bundle-SymbolicName and Bundle-Version headers, and are therefore sim-
ilar to the osgi.identity capability!
It may seem odd to model the bundle like this, but it makes a lot of sense.
Require-Bundle and Fragment-Host are clearly dependencies that need to be
mapped as requirements—therefore, there must be matching capabilities to satisfy
them! The two capabilities are in the osgi.wiring.bundle and osgi.wiring.host
namespaces for Require-Bundle and Fragment-Host , respectively.
We've discussed how requirements and capabilities are structured, and that a capabil-
ity must provide the right attributes to satisfy a requirement. Although this model has
an elegant simplicity, it isn't, unfortunately, the full story. In addition to attributes and
their namespaces, both requirements and capabilities can express directives that
affect the way they resolve.
7.1.3
Directives affecting the resolver
As we've said before, resolution is closely tied to provisioning. Nowhere is this more
clear than in the resolution directives that can be passed to the resolver through capa-
bilities and requirements. Directives aren't usually used directly to match require-
ments to capabilities (the mandatory directive is a notable exception), but instead
offer instructions to the resolver saying how they should be processed. If you find
yourself scratching—or banging!—your head about why a bundle won't resolve when
all the packages it imports are clearly available, check to see if there are any unsatis-
fied directives on the packages—there almost certainly will be!
Six standard directives can be applied to any namespace, which makes them partic-
ularly important to understand. These are the resolution directive, the mandatory
directive, the cardinality directive, the uses directive, the effective directive, and
the filter directive.
 
Search WWH ::




Custom Search