Add OSGi metatype descriptions to a Liberty feature project

We can add OSGi metatype descriptions to a Liberty feature that was created with the WebSphere Application Server Developer Tools by creating a metatype XML file. We can package that file in an OSGi bundle project.

  1. From the Project Explorer view, add a folder in the BundleContent folder, and name it OSGI-INF.

  2. Create a folder that is named metatype in the OSGI-INF folder.

  3. Create the metatype XML file in the metatype folder.

    The metatype XML file must have a .xml suffix. We can use any name for the file.

  4. Optional: Provide translated strings for your metatype definitions.

    1. Create a folder to contain the translated properties files.

      For example, we can create a subfolder that is named I10n in the OSGI-INF folder, and use the prefix metatype for your translated properties files.

    2. In the metatype XML file, specify the location of the folder that we created. Use the following example as a guide: 

        <metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0" 
        localization="OSGI-INF/I10n/metatype">

You created a metatype XML file, which we can use to add OSGi metatype descriptions to a Liberty feature.


What to do next

We can add information to the metatype XML file. To describe the configuration using the OSGi metatype service, package the metatype XML file in the OSGI-INF/metatype folder of one of the OSGi bundle projects, not in the Liberty feature project. For best results, put the metatype XML file in the same OSGi bundle as the code that receives and processes the configuration values, such as the associated ManagedService implementation. For more information, see Describing configuration using the OSGi Metatype service and Localize the configuration metadata.