Programatically create OSGi configuration field | Community
Skip to main content
ArpitVarshney
Community Advisor
Community Advisor
March 25, 2020
Solved

Programatically create OSGi configuration field

  • March 25, 2020
  • 1 reply
  • 1830 views

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.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Theo_Pendle

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  😕😕

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? 

1 reply

Theo_Pendle
Theo_PendleAccepted solution
Level 8
March 26, 2020

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  😕😕

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?