Java Reference
In-Depth Information
All resources define a capability named
osgi.identity
that determines their
type.
■
Resources provide a set of
Capability
objects describing the features they
provide.
■
Resources provide a set of
Requirement
objects describing the features they
need to run.
■
Resources use the
osgi.identity
and the optional
osgi.content
capabilities
to provide a set of named attributes describing the resource.
■
Despite the vague nature of
Resource
objects, these
rules mean that they aren't as complicated as you
might think. In figure 7.1, you can see that a
Resource
is not much more than a holder for
Requirement
and
Capability
descriptions.
Every resource exposes three mandatory attributes
through the
osgi.identity
capability:
■
type
—The type of the resource
■
osgi.identity
—The symbolic name or iden-
tity of the resource
■
version
—The version of the resource
Other attributes, such as the license, description, and
links to documentation, may also be included. Further
predefined attributes that broadly correspond to
other informational headers in the bundle manifest
file are defined by the
osgi.wiring.bundle
,
osgi.wiring.package
, and
osgi.wiring
.host
capabilities. Any of a resource's capabilities may also contain arbitrary keys and
values that are used in a resource type-specific way.
Resource
Capabilities
Requirements
Figure 7.1
Resources may have
requirements and capabilities.
IDENTITY OF RESOURCES
The identity of a resource is, unsurprisingly, defined by the attributes of the
osgi.identity
capability. For a particular
type
of resource, the combination of
osgi.identity
and
version
attributes provides a unique identifier, but it's impor-
tant to remember that, when comparing resources, they may not be of the
same type. This is why it's always important to refer to the whole
osgi.identity
capability. With the cornucopia of potential resource types,
OSG
i defines a standard
type for
OSG
i bundles (
osgi.bundle
) and fragments (
osgi.fragment
). Any
OSG
i
bundle modeled as a resource will have an identity type of
osgi.bundle
and an
osgi.identity
corresponding to its symbolic name, instantly separating it from the
crowd of configuration property and steamed pudding resources in the repository,
even if one of those puddings has exactly the same name and version as your bun-
dle (see figure 7.2).








