Howto: Creating your own Extension Point
23. October 2006
The loosely coupling of different application components is one of the most characteristic feature of Eclipse that should also be used by a RCP-developer. Especially because of the interfaces that are defined in eclipse with the extension-framework, you’re able to deliver products that are flexible and easy to customize. Therefore Eclipse gives you all needed tools and formalism to take with them.
If you’re developing an application based on the Eclipse-framework, you’re using primarily the extension-points provided by eclipse itself. The concept of the “late binding” can be and shall be used by a developer of a new eclipse application. Therefore the mechanism is really simple. You’re defining an extension point with a minimalist interface and extending the framework with your interface-implementation.
The article gives you an example how to extend your rich client application with your own extension-point. In addition the example source code should show how to set up a semantic context for your object structure and how the application behavior is affected.
The Scenario
Requirement is an application that shows a list of semantically typed objects that can be edited (fig.). Because the value is dependent from the current type is a definition of a general user interface not realizable. In addition the application should be designed in a way that makes the addition of a new data type as simple as possible.

The model contains of a list of value-holding objects. This value is typed by an object-attribute, that means it is syntactically structured in a different way.
Object1: A string as primitive Type
-
type: STRING
-
value: Mein String
Object2: A contact as complex type
-
type: CONTACT
-
value:
-
<contact>
-
<firstName>Tom</firstName>
-
<lastName>Seidel</lastName>
-
<company>Spirt Link GmbH</company>
-
</contact>
Object3: An address list as complex type
-
<br />
-
type: ADRESS
-
value:
-
<adresslist>
-
<adress active="true">
-
<street>Paul-Gordan-Straße 13</street>
-
<zip>91052</zip>
-
<city>Erlangen</city>
-
</adress>
-
<adress active="false">
-
<street>Nürnberger Straße 43</street>
-
<zip>91054</zip>
-
<city>Erlangen</city>
-
</adress>
-
<adress>
-
<street>Königsbrücker Straße 101</street>
-
<zip>01097</zip>
-
<city>Dresden</city>
-
</adress>
-
</adresslist>
Using Extension Points
The first step for the provision of an extension point is its definition. Therefore Eclipse has different wizards and editors. The definition is divided in two steps:
1. Declaration in the plugin.xml
For defining an extension point open the tab “Extension-Points” in the plugin editor and create with the wizard a new extension point with an id and a name. Please attend that the id is used at the declaration and the name if you want to use the point for your extension. After your inputs a schema editor will be opened where you can define a syntactical description of your extension-point.
2. Creating the schema
The schema of an extension-point is a syntactical description of the interface.
Search and activate plugins
If you’re accessing registered extension, the plugin-registry is searched for available extension-points and extension. This topic won’t be discussed further, because the Eclipse SDK itself provides the example source-code for picking these information.
Define your extension-point and you'll be halfway there.
Eclipse gives you also the possibility to document your extension-point. It is strongly recommended to use this feature for simplifying the use of your extension point. Especially implicit rules that can't be mapped with the formal schema should be documented in that way.
Implementing an extension
The implementation of an extension is in general the implementation of the defined interface, in our example a simple value-transfer. The abstract class that provides this functionality is already implemented in the “base-plugin”
An important point is the definition of scopes of an extension. When and where becomes an implementation of an extension point active? This question helps you to ensure the separation of single application components.
Conclusion
The definition and implementation of extension points and extensions is realizable in a very simple way. In addition it helps you exquisitely in designing a clear application.
Download
If you checkout the sources from cvs than checkout the following modules:
- de.spiritlink.extension.base
- de.spiritlink.extension.string
- de.spiritlink.extension.contact
- de.spiritlink.extension.adress
Download the Extension Example as RCP (Source included - 10 Mbyte)
CVS-Checkout (more info)



You helped me nail down a problem trying to implement update manager on my side. Thanks
Comment by dharana — 8. February 2008 @ 23:00
hi,I try to declare a extension point of my own, I create the extension point and the schema, and I export it as a plugin and put it to eclipse/plugins. then I decide to implement the point in another plugin ,but I can find the extension point. so why?
the jar’ including;
+com
+icons
+schema
+com.*.linkprotocol.exsd
+plugin.xml
Comment by wei. chen — 27. November 2008 @ 07:31
sorry , I cannot find the extension point I declared
Comment by wei. chen — 27. November 2008 @ 07:32
Hi!
Grate article for extensions point, I just started learning RCP.
But one thing where can we take the source code, CVS does not work and zip does not have the sources.
Many Thanks
Comment by alex — 19. December 2008 @ 17:25