OSGi:以编程方式将导入添加到捆绑包 [英] OSGi: programmatically add imports to a bundle

查看:177
本文介绍了OSGi:以编程方式将导入添加到捆绑包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从代码中将包添加到包的导入?我需要它,因为我使用依赖于反射并需要其他包的库,我不想为我开发的每个包手动将这些包添加到MANIFEST.MF

How can I add packages to a bundle's import from within code? I need it since I use libraries which rely on reflection and require other packages and I don't want to need to manually add those packages to MANIFEST.MF for each bundle I develop

推荐答案

你做不到。
Import-Packages在解决阶段进行评估。 (阶段已安装 - >已解决 - >活动)。

You cannot. Import-Packages are evaluated in the Resolution phase. (Phases are Installed -> Resolved -> Active ).

当捆绑包处于活动状态时,您的代码将被执行,因此无法添加Import-Packages。

Your code is executed when the bundle is Active, therefore too late to add Import-Packages.

你可以做两件事:


  • 导入 - 打包你要使用的包

  • 使用Dynamic-ImportPackage属性指定其分辨率可以延迟到执行时间的包

这篇关于OSGi:以编程方式将导入添加到捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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