title: OSGi Configuration Admin and MetaType Service
body: <p>I've been using the OSGi Configuration Admin to implement some basic configuration capability in our program. I now started looking into the <a href="https://osgi.org/specification/osgi.cmpn/7.0.0/service.metatype.html" rel="nofollow noreferrer">MetaType Service</a> specification because I need type information for each configuration property.</p>
  
  <p>It's unclear to me how these two services interact. The Configuration Admin deals with essentially untyped Key/Value pairs. The MetaType Service knows names and types (among other things) of configuration properties, but not their values. My goal is to dynamically generate a configuration/preferences dialog for all components which have a configuration and corresponding metatype information. According to the MetaType Service spec, the service was conceived to cover this exact use case. So I reckon it shouldn't be too difficult</p>
  
  <p>I can retrieve the metatype information with the following the sample code:</p>
  
  <pre><code>ServiceReference metatypeRef = bundleContext.getServiceReference(MetaTypeService.class.getName());
  MetaTypeService service = (MetaTypeService) bundleContext.getService(metatypeRef);
  MetaTypeInformation information = service.getMetaTypeInformation(myBundle);
  </code></pre>
  
  <p>After retrieving the MetaTypeInformation object for the required bundle, I have access to all the information contained in the metatype XML definition. In particular, it is possible to access the ObjectClassDefinition:</p>
  
  <pre><code>ObjectClassDefinition ocd = information.getObjectClassDefinition(pid, null);
  AttributeDefinition[] attributes = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
  </code></pre>
  
  <p>My questions are:</p>
  
  <ul>
  <li>Given the AttributeDefinition; how can I retrieve the actual value of the underlying property? I know its name, but not its value.</li>
  <li>How can I enumerate the metatype information for all components in all bundles that are currently present (active and inactive)? I know how to list all configurations through the Configuration Admin interface. It there perhaps a way to get to the MetaTypeInformation from the Configuration? </li>
  </ul>