Expand my Community achievements bar.

SOLVED

Programatically create OSGi configuration field

Avatar

Community Advisor

Hi Folks,

 

Is there any way to create OSGi configuration field dynamically?

For example: create a OSGi field dropdown whose values comes as a response from some API.

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Arpit  

  

Unfortunately I don't think so because configuration are built using Java backend classes annotated with annotations from org.osgi.service.metatype.annotations such as @ObjectClassDefinition to define a configuration and @AttributeDefinition to define an attribute of that configuration 

  

If we look at the @AttributeDefinition documentation we can see that it is processed at compile-time and not run-time, so no possibility for the backend to call an API to populate a list of option  

Selection_055.png

The fronted libraries loaded on the configuration page do not come from /libs but from /system/console/res/lib, so it's not possible to override them either. 

  

I'm curious, what's your use-case? 

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi Arpit  

  

Unfortunately I don't think so because configuration are built using Java backend classes annotated with annotations from org.osgi.service.metatype.annotations such as @ObjectClassDefinition to define a configuration and @AttributeDefinition to define an attribute of that configuration 

  

If we look at the @AttributeDefinition documentation we can see that it is processed at compile-time and not run-time, so no possibility for the backend to call an API to populate a list of option  

Selection_055.png

The fronted libraries loaded on the configuration page do not come from /libs but from /system/console/res/lib, so it's not possible to override them either. 

  

I'm curious, what's your use-case?