OSGi Declarative Services vs. ManagedService for configuring service?

女生的网名这么多〃 提交于 2019-11-28 21:37:17
Neil Bartlett

Yes, you can completely ignore ManagedService and ManagedServiceFactory and just use Declarative Services components. And yes I would recommend this approach.

Just think of this as different levels of abstraction. MS/MSF is the low-level API for config admin, and it is available even when you don't have a DS bundle running. The advantage of this is you can write configurable services without having a dependency on DS, which may be desirable for certain "system level" components.

However, if you are happy to depend on DS, e.g. for "application level" components, then using DS's built-in integration with config admin will make your life a lot easier.

couple of examples of building declarative services factories:

1) via config admin : carrot-osgi-scr-factory-cm

2) via component factory : carrot-osgi-scr-factory-ds

take a look on tests for use cases;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!