OSGi 包启动级别是如何定义的?
我正在使用 Apache felix,并希望在整个框架执行过程中保持启动级别。我预计根本不需要非常频繁地更改 bundle 的起始级别,Manifest.MF 中的一个条目似乎是最明智的。我已经到 org.osgi.framework.startlevel 但还没有看到一个实际的例子。
我也在使用 maven 和 maven-bundle-plugin,如果有一种优雅的方式将起始级别合并到 POM 中,那将是非常棒的。
最佳答案
Bundle 不会在构建时定义它们自己的起始级别;将 bundle 安装到框架中的管理员或代理定义了它。
核心框架在第 8 节中定义了一个Start Level 接口(interface)。引用:
The Start Level API provides the following functions:
Controls the beginning start level of the OSGi Framework.
Is used to modify the active start level of the Framework.
Can be used to assign a specific start level to a bundle.
Can set the initial start level for newly installed bundles.
最后两个与您在这里的查询有关。第 8.3.4 节—更改 Bundle 的起始级别—表明框架将永久存储分配的起始级别。
如果您使用的是 Apache Felix,您可以通过多种方式安装 bundle 并指定它们的启动级别,无论是显式还是允许它们继承已安装 bundle 的默认启动级别:
- Felix File Install (参见
felix.fileinstall.start.level
属性,虽然它不是per-bundle) - Felix Bundle Auto-Deploy (参见
felix.auto.install.<n>
property) - GoGo Shell Command (参见 the
bundlelevel
command)
另请参阅 felix.startlevel.bundle
property ,它控制通过上述以外的方式安装的 bundle 。
至于设置 list 属性(例如在构建时使用 Maven),曾经在 Equinox 中有一种方法可以做到这一点——现在已经弃用了——但是没有标准的方法让 bundle 向框架表明它是什么适当的启动级别应该是。
关于java - OSGi 包启动级别是如何定义的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7462259/