How to implement an OSGI dynamic metatype?

158 Views Asked by At

I would customize the OSGI-INF metatype (xml) in order to add attributes dynamically.

This is an example of a metatype input:

<AD id="Device-Operation"
      name="Device-Operation"
      type="String"
      cardinality="0" 
      required="false"
      default="NONE" 
      description="Operations"> 

     <Option label="None" value="NONE"/>  
     <Option label="Test" value="Test"/>     
     <Option label="OtherTest" value="OtherTest"/>     
</AD>

I need to build these select options dynamically.

Have I to create a service?

And how can I update these properties from the bundle?

Thank you very much in advance.

1

There are 1 best solutions below

2
On

You can register a MetatypeProvider OSGi service programmatically instead of declaring the metatype information in an XML file. By doing that, you can change re-register the service with new return values later.