当我们在 Eclipse 插件依赖项中有 `Required Plug-ins` 时,为什么我们需要 `Imported Packages`?

Why do we need `Imported Packages` when we have `Required Plug-ins` in Eclipse plugin dependencies?(当我们在 Eclipse 插件依赖项中有 `Required Plug-ins` 时,为什么我们需要 `Imported Packages`?)
本文介绍了当我们在 Eclipse 插件依赖项中有 `Required Plug-ins` 时,为什么我们需要 `Imported Packages`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发 Eclipse 应用程序时,MANIFEST.MF 中的依赖项选项卡有两列.

In developing Eclipse application, the dependencies tab in MANIFEST.MF has two columns.

一个是Required Plug-ins,另一个是Imported Packages.

当我们有必需的插件时,为什么还需要Imported Packages?

Why do we need Imported Packages when we have Required Plug-ins?

评论说这个插件依赖于没有明确标识他们的原始插件",但我不确定在什么情况下不想明确标识他们的原创插件,有什么好处?

The comment has it that "this plug-in depends without explicitly identifying their originating plug-in", but I'm not sure in what case one doesn't want to explicitly identify their originating plug-in, and what's the advantage of it?

相关问题 - Eclipse 包和插件有什么区别?

推荐答案

导入包提供了额外的间接级别,而不是需要包.

Importing a package provides an extra level of indirection over requiring a bundle.

考虑一些标准 API 的情况... org.standard.framework.假设有两家公司实现了这个 API,也许你有包 com.abc.frameworkcom.xyz.framework.这两个实现包都会导出 org.standard.framework 包.

Consider the case of some standard API... org.standard.framework. Suppose two companies implement this API, maybe you have bundles com.abc.framework and com.xyz.framework. Both of these implementation bundles would export org.standard.framework package.

现在假设,您需要一个 org.standard.framework 实现,但您并不特别关心是哪一个.如果您需要 com.abc.frameworkcom.xyz.framework 捆绑包,那么您将自己绑定到特定的实现.使用 import-package 指令,您可以让 OSGi 充当间接层.

Now suppose, you need an org.standard.framework implementation, but you don't particularly care which one. If you require either com.abc.framework or com.xyz.framework bundle, you are tying yourself to a particular implementation. With an import-package directive, you are letting OSGi serve as an indirection layer.

import-package 的另一个优点是,如果将一个包移动到另一个包,您的依赖项不需要更改.当捆绑包被分解或组合时,在重构期间可能会出现这种情况.

Another advantage of import-package is that your dependencies do not need to change if a package is moved to another bundle. This situation can arise during refactoring when bundles are broken up or combined.

由于这些原因,OSGi 规范编写者现在通常建议使用相对较新的 import-package 指令而不是 require-bundle.问题是并非所有的捆绑包都为此做好了准备.许多人在导出包时还没有指定版本.这使得 import-package 在许多情况下变得不切实际.

For these reasons, OSGi spec writers now generally recommend using the relatively newer import-package directive over require-bundle. The problem is that not all of the bundles are ready for this. Many do not yet specify a version when exporting a package. This makes import-package impractical in many cases.

这篇关于当我们在 Eclipse 插件依赖项中有 `Required Plug-ins` 时,为什么我们需要 `Imported Packages`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

VertX 3.9.7 when i receive the form quot;throw exceptionquot; Size exceed allowed maximum capacityquot;(VertX 3.9.7收到表单时抛出异常SIZE超出允许的最大容量QUOT;)
JDK11 Upgrade Fails - ClassNotFoundException jdk.internal.ref.Cleaner(JDK11升级失败-ClassNotFoundException jdk.inder.ref.Cleaner)
How to make Eclipse compile patched modules on JDK 9+ by passing the --patch-module javac option to my project compiler? (see pic)(如何通过向我的项目编译器传递--patch-MODULE javac选项,让Eclipse在JDK 9+上编译打了补丁的模块?(见图))
JavaFX Modular Application, java.lang.module.FindException: Module javafx.controls not found (Java 11, Intellij)(JavaFX模块化应用程序,java.lang.mode.FindException:未找到模块javafx.Controls(Java 11,IntelliJ))
Returning NumberFormatException form SimpleDateFormat in Java code(在Java代码中返回SimpleDateFormat形式的NumberFormatException)
SimpleDateFormat() not giving IllegalArgumentException on passing invalid date format(SimpleDateFormat()在传递无效的日期格式时未给出IlLegalArgumentException)