OSGi:有没有“最好的方法”?处理服务和寄存器?
我正在使用 OSGi 启动一个项目,在定义处理服务注册等的方式时,我面临着一个非常重要的选择...
如果我没有记错的话,我有三个选择:
- 通过实现服务侦听器来使用手动解决方案/em> 并处理我自己的寄存器(实际上可能不是最糟糕的选择)
- 使用声明式服务范例:看起来不错,但我感觉它现在有点过时了。我说得对吗?
- 使用 Spring DM 范例:它似乎是最新的范例,但我不确定它是否已经标准化。我是否需要一个特殊的 OSGi 实现来运行它(例如 Virgo/SpringDM Server ?),或者我可以在包含插件
org.springframework.*?
您对我的审讯有什么意见或信息吗?您有首选选择(为什么?)还是您使用我的列表中未包含的其他解决方案?
预先非常感谢。
I am starting a project with OSGi and I am facing a very important choice while defining the way I will handle service registration etc...
If I am not mistaken, I have three choices :
- Use manual solution by implementing service listeners and handling my own registers (maybe not the worst choice actually)
- Use the Declarative Service paradigm : Seems good but I have the feeling that it's now a bit deprecated. Am I right ?
- Use the Spring DM paradigm : It seems to be the latest paradigm but I am not sure it is well-standardized yet. Do I need a special OSGi implementation to run it (like Virgo/SpringDM Server ?) or can I use my classic OSGi platform as soon as it contains the plugins
org.springframework.*
?
Do you have any comments or information about my interrogations ? Have you a preferred choice (and why ?) or do you use an other solution not included in my list ?
Thanks very much in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
声明式服务 (DS) 并未被弃用,它们实际上是 OSGi 中处理服务绑定/取消绑定的最干净的方式。您可以手动执行此操作,这可能会更好,具体取决于您的用例,但通常 DS 都很好。 SpringDM 在底层使用了 Equinox,但他们已经为你包装了它,以使某些东西更有弹性。我从未尝试过 SpringDM,所以无法发表太多评论。
如果您计划将来使用/集成 Spring,请从 SpringDM 开始。否则,从 DS 开始。如果您需要做 DS 无法处理的事情,您可以使用服务跟踪器手动完成。 DS 和手动服务处理混合使用是可以接受的。
我认为您有第四种选择,称为“Blueprint”,在过去两年的某个时候,它被提议作为 DS 的替代品。我不知道他们去了哪里,但我认为 SpringDM 可能在内部使用它。
Declarative Services (DS) are not deprecated, they are in fact the cleanest way of handling service binding/unbinding in OSGi. You could do it manually, and this may be better depending on your use-cases, but generally DS are good. SpringDM uses Equinox underneath, but they have wrapped it for you to make certain things more Springy. I've never tried SpringDM so can't comment much.
If you are planning on using/integrating Spring in the future, start with SpringDM. Otherwise, start with DS. If you ever need to do something DS cannot handle, you can do it manually with service trackers. It is acceptable to mix DS and manual service handling.
I think you have a fourth option called "Blueprint" which was proposed as an alternative to DS sometime in the last 2 years. I don't know where they got to, but I think SpringDM might be using this internally.
除了 @omerkudat 的建议之外,您还可以查看 iPOJO它比 DS 更先进,但它不是官方规范的一部分。
In addition to @omerkudat advices, you can also take a look at iPOJO which is more advanced than DS, but it is not part of the official specification.