window
window

Reputation: 67

What is the best way to pass configurations to OSGI components?

I have a set of parameters that should be configured by the user. But they are just too much to send them through RESTful services or something similar. Besides there may be another set of configurations of same parameters.

Assume that my configurations are: p1, p2, p3, ... p10 I want to make possible having more than set of initialization of these configurations such as: (p1=x, p2=y, ... p10=1) (p1=a, p2=b, ... p10=10)

To do that I currently implement my OSGI component with metatype=true and configurationFactory = true options so that each instance of my component will have a set of configurations initialized. Then, I process the instances in a manager component.

So the question what do you suggest for passing configurations to OSGI components from user?

Thanks

Upvotes: 1

Views: 469

Answers (1)

Bertrand Delacretaz
Bertrand Delacretaz

Reputation: 6100

If this is really about configurations you should use the OSGi ConfigurationAdmin service. A console like the Apache Felix WebConsole can then be used to edit configurations.

If the values (or some values) can be different for each RESTful call to your application and they don't fit in a URL, you can make a POST request instead of a GET, and pass the values in the body of the request, in a suitable format.

Upvotes: 2

Related Questions