开发者

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

开发者 https://www.devze.com 2023-03-19 10:10 出处:网络
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...

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 p开发者_开发百科aradigm : 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消