在运行时修改 Bundle Manifest

发布于 2024-12-03 18:50:49 字数 488 浏览 1 评论 0原文

是否可以(如果是的话,安全)在捆绑包的生命周期内随时修改其清单(即大概仅在已安装和已解决之间)。

我想问这个问题的另一种方式是,

在安装之后,但在解决之前,清单是否已经完全评估(即进一步的更改将被忽略),使得更改为时已晚?

如果上述所有内容看起来都很荒谬..那么我的下一个问题是,是否有人认为有可能(没有令人讨厌的框架黑客)包装 MANIFEST 解析(即从类加载器步骤获取 META-INF/MANIFEST.MF捆绑)与自定义实现。

背景:考虑一个不基于 OSGi 的现有模块化框架,我希望通过提供无需修改即可部署现有“插件”基调的能力来简化向 OSGi 的迁移,在运行时,执行分析(“插件”定义良好,因此映射应该不难),将它们转换为真正的 OSGi 包,使用 BND 运行时操作生成 MANIFEST,该 MANIFEST 将用于代替潜在的不存在或非 osgi-bundle MANIFEST。

希望这是有道理的(@njbartlett!)

Is it possible (and if so, safe) to modify the MANIFEST of a bundle anytime during it's lifecycle (i.e. presumably only between INSTALLED and RESOLVED).

I guess another way to ask the question would be,

After INSTALLED, but before RESOLVED, is the MANIFEST already fully evaluated (i.e. further changes would be ignored) making it too late to change?

If all of the above seems absurd.. then my next question would be, does anyone think that it's possible (without nasty framework hacks) to wrap the MANIFEST resolution (i.e. the classloader step to get the META-INF/MANIFEST.MF from a bundle) with a custom impl.

Background: Consider an existing modularity framework, not based on OSGi, that I'd like to simplify the migration for, toward OSGi, by offering the ability to deploy the tone of existing "plugins" without modification, and at runtime, perform an analysis (the "plugins" are well defined so the mapping should not be hard) which converts them to true OSGi bundles, using BND runtime operations to generate a MANIFEST which would be used in place of the potentially none-existent or non-osgi-bundle MANIFEST.

Hopefully that makes sense (@njbartlett!)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情域 2024-12-10 18:50:50

为什么不定义一个 URL 方案来改变清单作为安装/更新过程的一部分?当框架通过 URLConnection 访问捆绑包时,您可以返回带有变异清单的变异捆绑包。这基本上就是网络捆绑支持的作用,它也应该适合您。

Why not define a URL scheme that mutates the manifest as part of the install/update process? When the framework accesses the bundle via your URLConnection, you can return a mutated bundle with the mutated manifest. This is basically what the web bundle support does and it should work for you too.

要走就滚别墨迹 2024-12-10 18:50:50

不,你不能这样做。在安装操作期间会读取整个 JAR 文件(以及 MANIFEST.MF)。为了更改该 JAR 中的任何内容,您必须更新捆绑包或卸载并重新安装。

至于你真正想要做什么,为什么不能在将 JAR 作为捆绑包安装之前通过 bnd 进行分析和转换呢?

No you can't do this. The whole JAR file (and therefore the MANIFEST.MF) is read during the install operation. In order to change anything in that JAR you would have to either update the bundle or uninstall and install again.

Regarding what you actually want to do, why can't you just perform the analysis and transformation through bnd before installing the JAR as a bundle?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文