在同一个 jar 中打包多个 OSGi 包 [英] Packing multiple OSGi bundles in the same jar

查看:90
本文介绍了在同一个 jar 中打包多个 OSGi 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 OSGi 平台非常陌生.

I am very new to the OSGi platform.

有一个 OSGi 包 B1 依赖于另一个包 B2,这很可能不是由容器提供的,我可以将这两个包打包在同一个 B2 中吗?代码>jar?

Having an OSGi bundle B1 that has a dependency to another bundle B2, which is very probably not provided by the container, can I package both bundles in the same jar?

如果是:怎么做?如果安装了 jar 并且已经安装了包,会发生什么?

If yes: howto do that? what would happen if the jar is installed and the bundle is already installed?

推荐答案

是的,你可以这样做......有点.

Yes you can do this... kind of.

通常 OSGi 包是 JAR 文件,因为它们需要有一个 META-INF/MANIFEST.MF.OSGi 框架无法直接读取您的多包"JAR.

Normally OSGi bundles are JAR files because they need to have a META-INF/MANIFEST.MF. The OSGi framework cannot directly read your "multi-bundle" JAR.

然而,在 OSGi 中安装包需要调用 BundleContext.installBundle 方法.这个方法有两种风格,一种是将 InputStream 作为参数;这个 InputStream 应该提供 OSGi 包的内容.因此,您可以使用 JarInputStream 读取大 JAR,将各个条目传递给 installBundle 方法.

However, installing bundles in OSGi involves calling the BundleContext.installBundle method. This method has two flavours, one of them takes an InputStream as a parameter; this InputStream should supply the content of the OSGi bundle. Therefore you can take your big JAR and read it with a JarInputStream, passing the individual entries to the installBundle method.

这篇关于在同一个 jar 中打包多个 OSGi 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆