使用 OSGI 如何将参数从主机传递到嵌入式包
最后我可能会提供一个帮助器,以便激活器可以导入和导出服务以及有关系统的其他类型的元数据。
我所说的参数是指一般的对象,也许是通过地图。如果一个包在安装另一个包时有一种将参数发送到起始包的机制,那就太好了。我想我可以在后面的捆绑包中包含一项服务并将其用作配置服务,但这似乎有点不优雅。
In the end i will perhaps provide a helper so that the activator can import and export services and other types of meta data about the system.
By parameters i mean objects in general, perhaps via a map. it would be great if one bundle when installing another had a mechanism to send parameters to the starting bundle. I suppose i could include a service on the later bundle and use it as a configuration service but that seems a bit unelegant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想将一些配置参数“发送”到启动包,您可以使用标准 OSGi 服务,例如 配置管理服务。如果您想传递任意对象,您可能应该使用 OSGi 服务注册表。
您能澄清一下您的问题吗? “主机”捆绑包和“嵌入式”捆绑包是什么意思?您想提供什么样的“帮手”?最重要的是,您希望将哪种参数从一个包传递到另一个包?
If you want to "send" some configuration parameters to a starting bundle you can use standard OSGi services like Configuration Admin Service. If you want to pass around arbitrary objects you should probably use OSGi service registry.
Could you please clarify your question? What you mean by "host" bundle and "embedded" bundle? What kind of "helper" do you want to provide? Most importantly what kind parameters you want to pass from one bundle to another?
要对捆绑包进行(预)运行时配置,您应该使用配置管理服务。对于 pojo 等,您可以遵循以下模式:
To do (pre-) runtime configuration of a bundle, you should use the Configuration Admin Service. For pojos etc you can follow this pattern: