RSS

Search Engine

Tuesday, June 29, 2010

Eclipse Extensions

1.1. What are Extension Points and Extensions?

Eclipse provides the concept of "extension points" and "extensions" to facilitate that functionality can be contributed to plugins by other plugins. Plugins which define extension points open themself up for other plugins. A extension points defines a contact how other plugins can contribute. The plugin which defines the extension point is also responsible for evaluating the contributions. Therefore the plugin which defines an extension point both defines the extension point and has some coding to evaluate contributions of other plugins.

A plugin which defines an "extension" contributes to the defined "extension point". The contributed can be done by any plugin. Contributions can be code but also data contributions, e.g. help context. Extensions to an extension points are defined in the plugins via the file "plugin.xml" using XML.

The information of the available extension points and the provided extensions are stored in the Eclipse "Extension Registry". The resolution of the extension points and provided extension happen as a plugin is the lifecyle status "resolved". This lifecycle status is defined by the OSGI runtime, Equinox, which is used by Eclipse.

To summarize:
  • A plugin defines an Extension Point: this plugin allow other plugins to add functionality based on the defined contact by the extension point

  • A plugin provides an Extension: This plugin added a contribution to an existing extension point.

1.2. Analysis

The concept of extension points allows to contribute functionality to plugins without changing the existing code of the plugin. This is a powerful concept as it allows to developed functionality decoupled. The extension mechanism is declarative, therefore the dependencies can be evaluated without loading any code. This allows lasy loading of plugins and therefore scales very well with lots of plugins.

1.3. Process of creating an extension point

A plugin which defines an extension points must do the following.

  • Define the extension point in the MANIFEST.MF

  • Write code to load the extensions to this extension point

  • Load / Call the extensions when needed

Extension points are defined via an XML schema file which is referred to in the the file plugin.xml. This XML schema file defines the details and the contract of the extension point. For example the following shows the relation to the schema file in the file "plugin.xml".

    





1.4. Tooling

Eclipse PDE provides powerful tooling to work with extension points. The usage of the PDE tooling will be demonstrated in the following example.

0 comments:

Post a Comment