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

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

问题描述

Eclipse 包(例如,在激活器代码中)如何在运行时找到依赖的 Bundle 实例?我想找到 Eclipse 选择的满足依赖要求的包,我不想自己解释清单.

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.

一个例子:我想在我当前的包所依赖的所有包中找到所有名为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()

您需要为所有已安装的捆绑包确定哪个会导出您的捆绑包正在导入的一个或多个包.实现这一点的最简单方法是调用 PackageAdmin.getExportedPackages(Bundle bundle) 并设置 bundles = null.这将返回所有导出包的数组.然后你需要迭代这个数组并调用 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 中查找依赖包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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