When should I use Import-Package and when should I use Require-Bundle?

后端 未结 6 1718
醉话见心
醉话见心 2020-12-02 13:58

OSGi allows for dependencies to be determined via Import-Package, which just wires up a single package (exported from any bundle), and Require-Bundle

6条回答
  •  遥遥无期
    2020-12-02 14:49

    I believe Import-Package gives you looser coupling and should be preferred. I use it when declaring dependencies on packages that I don't own, such as slf4j, and I can swap implementations as I wish. I use Require-Bundle when the dependency is something I have control over, such as my own bundles, because any important change would have gone through myself anyway.

提交回复
热议问题