Eclipse 包和插件有什么区别?

What#39;s the difference between Eclipse Packages and Plug-ins?(Eclipse 包和插件有什么区别?)

本文介绍了Eclipse 包和插件有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Dependencies 选项卡中,我可以在插件和包之间进行选择.他们之间有什么区别?对于 org.eclipse.compare,我在导入的包和插件中都有它.

In Dependencies tab, I have a choice between plug-ins and packages. What's the difference between them? For org.eclipse.compare, I have it in imported package and also in plug-ins.

在plugins目录下找到jar文件,但不知道org.eclipse.compare的包文件在哪里.

I find the jar file in plugins directory, but I don't know where the package file of org.eclipse.compare is located.

在导出菜单中,似乎只有导出到jar,而不是导出插件或包.如何导出包?

In the export menu, it seems like that there seems to be only exporting to jar, not exporting a plugin or packages. How can I export packages?

根据这篇文章 - 如何从 Eclipse 导入包? 和shiplu 的回答.这就是我明白的.如果我错了,请纠正我.

Based on this post - How to import a package from Eclipse? and shiplu's answer. This is what I came to understand. Please correct me if I'm wrong.

  1. 在eclipse中,当我使用come external class时,我可以使用Quick-Assistant或Organize imports (Ctrl-Shift-O)来解析引用.Eclipse 为我正在处理的项目添加包含 Imported Packages 中的类的包.一个包可以包含多个类(类型).Eclipse 了解包含该包的插件,并解决参考问题.
  2. 一个插件(jar 文件)可以包含多个包.通过在依赖项选项卡中指定所需的插件,我们可以引用eclipse IDE中所有java项目的所有包(以及包中的类).
  1. In eclipse, when I use come external class, I can use Quick-Assistant or Organize imports (Ctrl-Shift-O) to resolve the reference. Eclipse adds the package that contains the class in Imported Packages for the project that I'm working on. A package can contain multiple classes (types). Eclipse understands what plugin contains the package, and resolve the reference issues.
  2. A plug-in (jar file) can contain multiple packages. By specifying a required plug-ins in the dependencies tab, we can reference all the packages (and classes in the packages) for all the java projects in the eclipse IDE.

根据我的经验,我必须添加所有依赖项才能使无头 RCP 独立(http://prosseek.blogspot.com/2012/12/headless-rcp-standalone.html).

And from my experience, I had to add all the dependencies in order to make headless RCP standalone (http://prosseek.blogspot.com/2012/12/headless-rcp-standalone.html).

推荐答案

Eclipse 插件基本上是一个 OSGi 包,带有附加的 plugin.xml 文件,Eclipse IDE 可以理解和解释.

An Eclipse plug-in is basically an OSGi bundle with additional plugin.xml file which Eclipse IDE understands and interprets.

因此,您的问题的答案在于 OSGi 规范和 OSGi 编程模型,因为简单地说,Eclipse 是一个运行在名为 Equinox 的 OSGi 实现上的应用程序.

So the answer to your question lies in the OSGi specification and the OSGi programming model, since, very simply put, Eclipse is an Application running on implementation of OSGi called Equinox.

OSGi 是关于拥有模块化应用程序的,因此它定义了多个级别的模块化.一个这样的级别是捆绑级别(模块级别)的模块化,更细粒度的级别是包级别的模块化.

OSGi is all about having modular applications and so it defines several levels of modularity. One such level is a bundle-level (module-level) modularity and more fine grained level is the package level modularity.

因此,您可以拥有由 db-bundle(提供数据存储服务)、app-domain-bundle(提供应用程序域服务)和远程组成的 OSGi 应用程序(一组捆绑包;eclipse 就是这样)-bundle(例如,通过 REST 向 Web 公开您的应用程序).

So you can have your OSGi application (a set of bundles; eclipse is just that) which consists of db-bundle (which provides data store services), app-domain-bundle (which provides your application domain services) and remote-bundle (which exposes to the web your application via REST for example).

然后你说 remote-bundle 依赖于 domain-bundle,而 domain-bundle 又依赖于 db-bundle.这一切都很好,但削弱了 OSGi 提供的固有模块化,因为您基本上将您的应用程序限制为 db-bundle 和 remote-bundle 的特定实现,即它们提供的服务的特定实现.

And then you say remote-bundle depends on domain-bundle which depends on db-bundle. Which is all good, but cripples the inherent modularity OSGi provides, because you are basically restricting your application to specific implementations of db-bundle and remote-bundle i.e. to specific implementations of the services they provide.

相反,您可以不在包之间而是在包之间建立上述依赖关系,即建立服务级别的依赖关系.然后你说 domain-bundle 需要 dbstore.service 包才能运行,它不关心哪个包提供它只需要该服务的实例才能工作.因此,您可以拥有多个提供 dbstore.service 实现的包,并且域包可以在运行时选择要使用的服务.

Instead, you can establish the above dependencies not between bundles but between packages i.e. establish a service-level dependencies. Then you say domain-bundle requires dbstore.service package to run, it doesn't care which bundle provides it it just needs an instance of this service to be able to work. So you can have multiple bundles providing implementations of the dbstore.service, and the domain-bundle can pick and choose at runtime what service to use.

用几句话来解释 OSGi 概念真的很难,我真的建议你在网上搜索一下,甚至看看 OSGi 规范.

It is really hard to explain OSGi concepts in just a several sentences, I'd really suggest you dig around the web on this and maybe even have a look at the OSGi specification.

另一种解释方式是,bundle/plug-in 是一个带有特定结构和元数据描述符(MANIFEST.MF 和 plugin.xml)的 jar 文件,它用 Java 语言概念描述其内容——java 封装和服务这个特定的 jar 包含并将公开给 OSGi 运行时,以便它们可以被其他包使用.IE.捆绑包是可部署的物理实体,而描述符是有关实际部署内容的元数据.

Another way to explain it is to say that bundle/plug-in is a jar file with specific structure and metadata descriptors (MANIFEST.MF and plugin.xml), which describe its contents in Java language concepts - which java packages and services this specific jar contains and will expose to the OSGi runtime so that they can be consumed by other bundles. I.e. the bundle is the physical deployable entity while the descriptors are metadata about what actually is being deployed.

包或服务级别的依赖也有一些缺点,正如 Lii 在下面的评论中指出的那样,主要是它增加了依赖模型的复杂性和动态性.看看下面她或他的评论 - 值得一读!

Package or Service-level dependencies also have some drawbacks, as Lii points out in the comments below, the main one being that it adds complexity and dynamics to the dependency model. Have a look at her or his comment below - it is worth reading!

这篇关于Eclipse 包和插件有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Eclipse 包和插件有什么区别?

基础教程推荐