Find the dependent bundles in Eclipse at runtime(在运行时在 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 中查找依赖包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在运行时在 Eclipse 中查找依赖包
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01