问题描述
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 中查找依赖包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)