在运行时在Eclipse中查找依赖的bundle [英] Find the dependent bundles in Eclipse at runtime

查看:275
本文介绍了在运行时在Eclipse中查找依赖的bundle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Eclipse捆绑包(例如,激活码)如何在运行时找到依赖的Bundle实例?我想找到Eclipse选择的bundle来满足依赖关系的要求,我不想自己插入清单。

How can an Eclipse bundle (eg. within activator code) find the dependent Bundle instances at runtime? I would like to find the bundles that Eclipse has choosen to satisfy the dependency requirements, I do not want to interprete the manifest myself.

一个例子:我想在我的当前bundle依赖的所有bundle中找到名为marker.txt的所有资源。也是传递依赖。为了实现这一点,我需要能够找到所有这些软件包开始。

An example: I would like to find all resources named "marker.txt" in all bundles on which my current bundle depends upon. Also the transitive dependencies. In order to accomplish this I need to be able to find all these bundles to begin with.

推荐答案

没有简单的方法确定依赖。
最好的方法是通过PackageAdmin接口。具体参见PackageAdmin和getImportingBundles的OSGi规范: http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/ExportedPackage.html#getImportingBundles()

There is no easy way to determine the dependency. The best way is to go through the PackageAdmin interface. See the OSGi spec for PackageAdmin and getImportingBundles in particular: http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/ExportedPackage.html#getImportingBundles()

您需要确定所有已安装的软件包,哪些软件包导出您的软件包导入的一个或多个软件包。实现此目的的最简单的方法是使用bundles = null 调用 PackageAdmin.getExportedPackages(Bundle bundle)。这将返回所有导出包的数组。然后,您需要迭代此数组并调用 ExportPackage.getImportingBundles()

You need to determine for all installed bundles, which one exports one or more packages that your bundle is importing. The easiest way to achieve this is to call PackageAdmin.getExportedPackages(Bundle bundle) with bundles = null. This returns an array of all exported packages. You then need to iterate of this array and call ExportPackage.getImportingBundles().

这篇关于在运行时在Eclipse中查找依赖的bundle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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