java - 如何根据其符号名称检索 Bundle?

标签 java osgi

BundleContext 的文档说它可以让你

  • 获取框架中安装的包列表。
  • 获取 bundle 的 Bundle 对象。

但是,没有getBundle(String symbolicName)方法,只有getBundle(long id)(和不合适的getBundle(String location). 当然,可以调用 getBundles() 并遍历返回的数组,但是有更好的方法吗?

最佳答案

我认为遍历 getBundles() 的数组很好。也许它根本不应该存在,因为符号名称不能唯一标识一个包。也许 getBundles(String symbolicName)...

来自 OSGi 服务平台核心规范,第 4 版,版本 4.3:

3.6.2 Bundle-SymbolicName

The Bundle-SymbolicName manifest header is a mandatory header. The bundle symbolic name and bundle version identify a unique bundle. This does not always imply that this pair is unique in a framework, in certain cases the same bundle can be installed multiple times in the same framework, see Bundle Identifiers on page 89.

引用的第 89 页(实际上是第 95 页):

4.4.1 Bundle Identifiers

[...]

Though the pair is unique, it is possible to install the same bundle multiple times if the org.osgi.framework.bsnversion framework launching property is set to multiple.

关于java - 如何根据其符号名称检索 Bundle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7977947/

相关文章:

java - 停止引用的服务后终止 OSGI 蓝图包

java - 当 Junit 使用 Gradle 测试成功时自动 Git 提交

java - 相当于 C# 中的 Java 元注释

java - 尝试启动 osgi 包时发生 BundleException

java - 在嵌入 Android 的 Knopflerfish 上启动 Bundle 不起作用

java - 类型 'org/eclipse/equinox/http/servlet/HttpServiceServlet'(当前帧,堆栈[0])不可分配给 'javax/servlet/http/HttpServlet'

java - JSP GlassFish 错误

java - 以下循环的(最坏情况)时间分析是什么?

java - 使用 Apache POI 确定 MS Excel 文件类型

Java OSGI。 Maven vs Eclipse+Ant - 最佳实践