将配置传递给 OSGI 组件的最佳方法是什么?
我有一组应由用户配置的参数。但它们实在太多了,无法通过 RESTful 服务或类似的方式发送它们。除此之外,可能还有另一组相同参数的配置。
假设我的配置是:p1, p2, p3, ... p10 我希望能够对这些配置进行多组初始化,例如: (p1=x,p2=y,...p10=1) (p1=a, p2=b, ... p10=10)
为此,我目前使用 metatype=true 和 configurationFactory = true 选项实现我的 OSGI 组件,以便我的组件的每个实例都会初始化一组配置。然后,我在管理器组件中处理实例。
那么问题是,您建议如何将用户的配置传递给 OSGI 组件?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这确实与配置有关,您应该使用 OSGi ConfigurationAdmin< /a> 服务。然后可以使用像 Apache Felix WebConsole 这样的控制台来编辑配置。
如果对应用程序的每个 RESTful 调用的值(或某些值)可能不同,并且它们不适合 URL,则您可以发出 POST 请求而不是 GET,并在请求正文中传递值,以合适的格式。
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.