简体   繁体   English

OSGi:是否有处理服务和注册的“最佳方式”?

[英]OSGi : Is there a 'best way' to handle service and registers?

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...我正在使用 OSGi 开始一个项目,在定义处理服务注册等的方式时,我面临着一个非常重要的选择......

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.使用Spring DM范式:它似乎是最新的范式,但我不确定它是否已经完全标准化。 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.* ?我是否需要一个特殊的 OSGi 实现来运行它(比如Virgo/SpringDM Server ?)或者我可以使用我的经典 OSGi 平台,只要它包含插件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.首先十分感谢。

Declarative Services (DS) are not deprecated, they are in fact the cleanest way of handling service binding/unbinding in OSGi.声明式服务 (DS) 并未被弃用,它们实际上是在 OSGi 中处理服务绑定/取消绑定的最简洁方式。 You could do it manually, and this may be better depending on your use-cases, but generally DS are good.您可以手动完成,根据您的用例,这可能会更好,但通常 DS 很好。 SpringDM uses Equinox underneath, but they have wrapped it for you to make certain things more Springy. SpringDM 在下面使用 Equinox,但他们为您包装了它以使某些东西更具弹性。 I've never tried SpringDM so can't comment much.我从未尝试过 SpringDM,所以不能发表太多评论。

If you are planning on using/integrating Spring in the future, start with SpringDM.如果您计划将来使用/集成 Spring,请从 SpringDM 开始。 Otherwise, start with DS.否则,从 DS 开始。 If you ever need to do something DS cannot handle, you can do it manually with service trackers.如果您需要做一些 DS 无法处理的事情,您可以使用服务跟踪器手动完成。 It is acceptable to mix DS and manual service handling.可以将 DS 和手动服务处理混合使用。

I think you have a fourth option called "Blueprint" which was proposed as an alternative to DS sometime in the last 2 years.我认为您有第四个选项,称为“蓝图”,它在过去 2 年的某个时候被提议作为 DS 的替代品。 I don't know where they got to, but I think SpringDM might be using this internally.我不知道他们去了哪里,但我认为 SpringDM 可能在内部使用它。

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.除了@omerkudat 建议之外,您还可以查看比 DS 更高级的iPOJO ,但它不是官方规范的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM