OSGi在Required-Bundle和Imported-Package上的类加载



对于OSGi bundle,我们可以通过Required-Bundle或Imported-Package来添加依赖。现在我有下面的case:

bundle A和bundle B都导出相同的包,但bundle B的版本更高,如:

bundle A:
   Exported Packages:
     xxx.a,
     xxx.b,
     xxx.c
bundle B:
   Exported Packages:
     xxx.a; version="5.0.0",
     xxx.b; version="5.0.0",
     xxx.c; version="5.0.0"

bundle C依赖于包a, b, C,所以它将a添加到它的Required-Bundle列表中,如

bundle C:
     Required Bundles:
       A

假设bundle A和B都在框架中被解析。那么在解析bundle C时,哪些包/类是由C加载的,是A中的类还是B中的类?我想是a,我说的对吗?

是的,使用来自A的包是因为您需要bundle A。

请注意,大多数OSGi开发人员认为Require-Bundle已被弃用。

最新更新