.kar Apache Karaf 文件是否仅用于公开功能?

Are .kar Apache Karaf files meant to expose features only?

我对 OSGi 和 Karaf 还很陌生,我仍然对这些概念和架构有所了解。

我的问题与使用 karaf-maven-plugin 创建的 .kar 文件有关。

.kar 文件是否意味着只将功能安装到 Karaf 运行时?如果我们创建一个包并将其重命名为 .kar 而不是 .jar 会怎样?这是 .kar 文件的有效用例吗?

谢谢

不,kar 文件远不止于此,因为它是一种机制,不仅可以提供 features.xml,还可以提供任何相关的 OSGi 包、配置文件等。在单个工件中。

这也是它包含强制性 repository/ directory (basically containing all OSGi bundles necessary for any of the features described by the features.xml in a Maven repository-style structure) and an optional resources/ 目录(包含功能引用的所有其他资源)的原因。

要获得完整的示例,您可以查看 Apache Karaf 框架存档:

其中包含构成自定义 Karaf 安装基础并提供基本功能集的所有基本资源:

META-INF/
...
META-INF/MANIFEST.MF
...
repository/
... OSGi bundles referenced by the features and the features.xml itself ...
resources/
resources/bin/
... scripts ...
resources/data/
...
resources/deploy/
...
resources/etc/
... configuration files ...
resources/lib/
... (non-OSGi) libraries needed (e.g. endorsed, extension, boot classpath) ...
resources/system/
... OSGi framework implementation(s) and related libraries ...