有多种方法可以将依赖包部署到 OSGi 容器。这里是其中的一些:
1 Felix OBR 包存储库
您首先需要使用诸如 bindex 之类的工具为可用的捆绑软件创建一个 XML 索引文件。如果您使用的是 maven-bundle-plugin,那么它会自动在 ~/.m2/repository/repository.xml 中维护一个 OBR 索引。
使用 OBR 命令行界面加载索引:
> obr:addUrl file:/Users/derek/.m2/repository/repository.xml
然后让 OBR 部署您的目标包,并根据 OBR 索引确定依赖项:
> obr:deploy com.paremus.posh.sshd
Target resource(s):
-------------------
Paremus Posh Ssh Daemon (1.0.23.SNAPSHOT)
Required resource(s):
---------------------
Paremus Command API (1.0.23.SNAPSHOT)
Optional resource(s):
---------------------
Paremus Config Admin Commands (1.0.23.SNAPSHOT)
Paremus OSGi & LDAP Types (1.0.23.SNAPSHOT)
2 阿帕奇卡拉夫
Karaf 支持“功能”,它们基本上是提供该功能所需的捆绑包列表:
karaf@root> features:info obr
Description of obr 2.0.0 feature
----------------------------------------------------------------
Feature has no configuration
Feature has no dependencies.
Feature contains followed bundles:
mvn:org.apache.felix/org.apache.felix.bundlerepository/1.6.4
mvn:org.apache.karaf.shell/org.apache.karaf.shell.obr/2.0.0
mvn:org.apache.karaf.features/org.apache.karaf.features.obr/2.0.0
karaf@root> features:install obr
3 日食处女座
Virgo 使用计划来定义组成应用程序的工件,它能够从本地和远程存储库自动提供应用程序的依赖项,包括捆绑包、计划、计划存档 (PAR) 和配置。
4 帕雷穆斯敏捷
Nimble 使用 OBR(或它自己的扩展)存储库索引,自动部署激活目标包所需的所有依赖包(并在目标包停止时卸载它们)。它还可以检测其他依赖项,例如 WAB 包需要 Web 扩展程序并根据可配置策略自动安装一个。
Nimble 也可以配置为启动 Glassfish,以便其功能可用于 Glassfish 容器中的捆绑包。
下面的示例还显示了在激活 sshd 时会自动安装日志记录支持:
$ posh
________________________________________
Welcome to Paremus Nimble!
Type 'help' for help.
[denzil.0]% nim:add --dry-run com.paremus.posh.sshd@active
-- sorted parts to install --
4325 osgi.resolved.bundle/ch.qos.logback.core:0.9.22
-- start dependency loop --
5729 osgi.resolved.bundle/com.paremus.util.logman:1.0.23.SNAPSHOT
5727 osgi.active.bundle/com.paremus.util.logman:1.0.23.SNAPSHOT
3797 osgi.resolved.bundle/ch.qos.logback.classic:0.9.25.SNAPSHOT
3792 osgi.resolved.bundle/slf4j.api:1.6
-- end dependency loop --
436 osgi.resolved.bundle/org.apache.mina.core:2.0.0.RC1
6533 osgi.resolved.bundle/sshd-core:0.3
398 osgi.resolved.bundle/com.paremus.posh.sshd:1.0.23.SNAPSHOT
396 osgi.active.bundle/com.paremus.posh.sshd:1.0.23.SNAPSHOT
(免责声明:我是 Paremus 的开发人员)
5 阿帕奇·费利克斯·戈戈
gogo 是新的 RFC147 标准命令行 shell。它已经在 Felix、Karaf、Nimble 中使用,并且很快将在 Glassfish 中使用。
Gogo 允许您以脚本的形式运行任何可以交互键入的命令。因此,您可以生成要安装的捆绑包列表并将其转换为脚本,甚至可以从工作配置中捕获已安装的捆绑包,以便可以从头开始重新创建它。