Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Eclipse Packages and Plug-ins?

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.

enter image description here

enter image description here

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

enter image description here

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?

enter image description here

ADDED

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. 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.

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).

like image 849
prosseek Avatar asked Dec 19 '12 20:12

prosseek


2 Answers

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

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 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.

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).

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.

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.

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.

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.

EDIT: 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!

like image 67
Svilen Avatar answered Oct 11 '22 07:10

Svilen


You use Imported Packages when you want to use a specific package but do not care which plugin provides it. OSGI will choose one for you.

like image 1
Cratylus Avatar answered Oct 11 '22 09:10

Cratylus