Adding OSGi metatype descriptions to a Liberty feature project

You 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. You can package that file in an OSGi bundle project.

Procedure

  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. You 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, you 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 you 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">

Results

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

What to do next

You can add information to the metatype XML file. To describe your configuration by using the OSGi metatype service, package the metatype XML file in the OSGI-INF/metatype folder of one of your 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 by using the OSGi Metatype service and Localizing the configuration metadata.