The mechanism, implemented in the Metatype Bundle, for mapping management operations to metatypes is based on the availability of Metatype Providers as services in the OSGi framework.
According to the OSGi Metatype Specification, metadata is exported via a org.osgi.service.metatype.MetaTypeProvider. The org.osgi.service.metatype.ObjectClassDefinition and org.osgi.service.metatype.AttributeDefinition instances of a Metatype Provider contain sufficient information to automatically build rudimentary user interfaces. They can also be used to augment dedicated interfaces with accurate validations.
To register a new metadata, accessible through the Metatype API, a bundle should register its Metatype Provider as a service in the OSGi framework under the org.osgi.service.metatype.MetaTypeProvider interface.
Metadata type and version can be indicated by the values of the "metadata.type" (MetypeProviderExtern.METADATA_TYPE) and "metadata.version" (MetypeProviderExtern.METADATA_VERSION) registration properties, respectively.
If no type and version are indicated, the Metadata Manager assumes that the corresponding Metatype Provider is designed for the Configuration Admin service (see the Config Bundle description for more information about Configuration Admin metadata). This is done for backward compatibility and for handling the metatyping, defined in the OSGi Configuration Admin Specification.
To take advantage of the Extended Metatype API's features, you have to implement the following interfaces, extending the OSGi Metatype API:
Interface to Implement |
Additional Functionality |
|---|---|
MetypeProviderExtern |
Creates metadata of a specified type and version, which can also contain configuration objects. As the MetatypeProviderExtern interface extends com.prosyst.util.io.Externalizable, you can serialize the metadata of the Metatype Provider and make it available to remote applications over PMP or another communication mechanism. The MetatypeProviderExtern implementation should be registered as a service in the OSGi framework. |
ObjectClassDefinitionEx |
Provides:
ObjectClassDefinitionEx instances should be returned by the getObjectClassDefinition method of the corresponding MetaTypeProvider. |
AttributeDefinitionEx |
Provides:
AttributeDefinitionEx instances should be supplied by the corresponding ObjectClassDefinition. |
Implementation of programming code to provide metadata seems to be a time- and effort-consuming process, so we suggest using the more convenient solution for metadata definition based on XML files.