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

后端 未结 6 1724
醉话见心
醉话见心 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:40

    Avoid Import-Package. As packages provide many-to-many relationships between bundles, they are prone to dependency cycles that are hard to detect and avoid.

    Require-Bundle on the other hand, references a single bundle, making dependency graph protected from cycles by a trivial build-time check. With Require-Bundle it is much easier to build layered architecture with isolated lower level of abstraction.

提交回复
热议问题