|Extensions and Extension Points [message #584291]
||Wed, 05 November 2008 10:57
| Paul Richardson
Registered: July 2009
I have recently moved from Netbeans RCP over to Eclipse RCP and was
wondering if someone could fill me in on a small but rather important
piece of information.
My application consists of several plugins each offering an additional
service to the user. The service framework offered in Netbeans allowed
for this in that I created an interface and implementation for some
functionality then offered up the implementation as a service. When the
module was loaded by Netbeans, the implementation instance was loaded
into a registry and I could get at it by looking it up.
I understand that the closest approximations to this functionality in
Eclipse is either OSGi services or extensions / extension points. I have
opted for the latter.
Plugin A offers extension point detailing a class that implements a
When something happens (button pressed for example), I wish to get the
implementation conforming to the known interface. Currently, this is
what I do.
String extPointID = "skeleton.domainObject";
IExtensionPoint extPoint =
if (extPoint == null)
IExtension extensions = extPoint.getExtensions();
for (int i = 0; i < extensions.length; ++i)
IConfigurationElement configElements =
for (int j = 0; j < configElements.length; j++)
IConfigurationElement element = configElements[j];
IDomainObject domain = (IDomainObject)
catch (Exception ex)
// Do something useful with this
As you see, I use "IConfigurationElement.createExecutableExtension" to
first create a class conforming to that denoted by the tag "class". Once
I have this class, I throw it away in favour of a singleton instance
that may or may not already have been created by Plugin A.
This process is very useful for creating a brand new class conforming to
the extension point. However, is there a simpler way of finding already
instantiated classes, in the vein of services. Does eclipse have a
registry of classes already instantiated by virtue of the plugins activated?
Is OSGi services the preferred way to go with this maybe?
Any help much appreciated.
Powered by FUDForum
. Page generated in 0.02057 seconds