As well as being a user of extension points, a plug-in can provide its own extensions for other plug-ins. Extension points allow loose coupling of functionality '" your plug-in exposes a set of interfaces and an extension point definition for others to use.
Extension Point Definition
You can create your extension point through the plugin.xml file, or through the Add button in the Extension Points tab of the plug-in editor.
For identifying your extension point you need to provide a unique identifier and a human readable name. At this point you can also point to a schema file and edit it afterwards. An extension point schema must have .exsd as its suffix.
Figure 1: The New Extension Point Wizard
Defining an Extension Point Schema
The PDE provides an editor for defining your .exsd file, consisting of three tabs. First, the Overview tab allows you to provide documentation and examples for your extension point. This is an essential step if you want your extension point to be adopted. Next, the Definition tab presents a graphical way to define your schema, while the Source tab allows editing of the .exsd XML definition.
Figure 2: The Extension Point editor
When creating your extension point, you will first want to create one or more elements with attributes that will be used. Each extension point attribute has a number of associated properties:
||The name of the extension point attribute.
||Whether the attribute is deprecated or not.
||Whether the attribute is optional, required or default. Default allows you to specify a value for the attribute if it hasn't been used.
||The available types are Boolean, String, Java, Resource and Identifier. While Boolean and String are self '"explanatory, Resource should be used if the attribute is a file. Identifier provides a reference id for the extension point.
||If the type is Java this must be the name of the class that the attribute must extend.
||If the type is Java this must be the name of the class that the attribute must implement.
||If the type is String this Boolean value indicates whether the attribute should be translated.
||If the type is String this can be used to limit the choice of value to a list of strings.
||If the type is Identifier, this provides the id of the extension point that you want to reference. This will allow implementers of the extension point to easily find the id, without having to look through the plug-in registry.
Once you have created your elements and attributes for the extension point, the element can be added to a sequence for this extension. You can control the multiplicity of your extension here.
The mapping of XML to extension point declaration is simple; for users of your point, an xml element in the extension point will always appear on the left hand side tree, as part of the extension point declaration, while the xml attributes will appear as extension point attributes.
The Code Behind an Extension Point
With the extension point defined, the producer of this needs to provide some implementation that makes use of any extension point contributions.
To get a list of all the implementers of your extension point you can query the extension registry as follows, providing your extension point identifier as the parameter.
IConfigurationElement config = Platform.getExtensionRegistry()
To use the implementing extension point, you can get the object from the IConfigurationElement.
final Object o = config[i].createExecutableExtension('class');