| Free tutorials for Java, Eclipse and Web programming |
Version 1.0
Copyright © 2008 - 2009 Lars Vogel
20.04.2009
| Revision History | ||
|---|---|---|
| Revision 0.1 - 0.7 | 18.09.2008 | Lars Vogel |
| Created article | ||
| Revision 0.8 | 05.04.2009 | Lars Vogel |
| Added explanation Extension point vrs. Extension | ||
| Revision 0.9 | 19.04.2009 | Lars Vogel |
| Improved overview part | ||
| Revision 1.0 | 20.04.2009 | Lars Vogel |
| Introducted ISafeRunnable | ||
Table of Contents
Extension Points allow that functionality is contributed to a specific plugin which defines this extension point. The functionality can then be contributed by any plugin which defines an extension for the defined extension point.
So an overview:
Extension Point: Defines the possibility to add functionality
Extension: Uses the extension point to provide functionality, also known as contributions
Functionality can be code but also non-code related contributions, e.g. help context.
The plugin which defines extension points defines a contract for other plugins how these plugins could provide functionality via this extension point.
The plugin which defines the extension point is also responsible for evaluating the contributions.
To define a extension point you perform the following:
Design the extension point
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 the file plugin.xml. For example the following show the extension point which will defined in the following example.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension-point id="de.vogella.extensionpoint.greeters" name="Greeters" schema="schema/de.vogella.extensionpoint.greeters.exsd"/>
<extension
id="application"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="de.vogella.extensionprovider.simple.Application">
</run>
</application>
</extension>
</plugin>
The extension point refers to an XML Schema which defines the details of the extension point.
Eclipse provides for both files a powerful editor which the following example will demonstrate.