Java Reference
In-Depth Information
9.2.2
Metatype Service
Assume for a moment that you're deploying a new bundle for the first time into a
framework that has your Configuration Admin shell command available. If this new
bundle provides some services that are configurable, you can use your shell command
to configure it, right? Unfortunately, because this bundle is new to you, you have no
idea which properties it accepts, nor which ones are required for it to operate. In this
kind of scenario, it would certainly be helpful if the bundle could convey to you what
a valid configuration look likes.
The OSG i standard Metatype Service makes this possible. It aggregates metatype s
(descriptions of types) contributed by bundles and allows others to look up these
definitions. Using this service allows you to introspect what a managed service accepts
as a valid configuration and also validate configurations against these schema, which
are subject to the same update and versioning mechanisms as the bundles that pro-
vide them.
As you can see in figure 9.6, there are two ways to provide metatype information
about your managed services:
A bundle can contain XML resources in its OSG I- INF /metatype directory, which
are picked-up by the Metatype Service using the extender pattern.
A managed service can implement a second interface called MetaTypeProvider .
If for some reason a bundle does both, only the XML resources are considered, and
the MetaTypeProvider service is ignored.
From a client perspective, the Metatype Service defines a dynamic typing system
for properties. This allows you, for example, to construct reasonable user interfaces
dynamically. The service itself provides unified access to the metatype information
provided by deployed bundles. A client can request MetaTypeInformation associated
with a given bundle, which in turn provides a list of ObjectClassDefinition objects
for this bundle. An object class contains descriptive information and a set of name-
value pairs. Here's what this looks like for the example echo server:
MetaType
Service
OSGI-INF/
metatype
XML resource
Managed
Service
ManagedService
Factory
Figure 9.6 Metatype Service overview
 
Search WWH ::




Custom Search