Extension points and the registry

While the "bundle" aspects of a plug-in may be interesting to the runtime plug-in and runtime tools, it is much more common that a plug-in is concerned with what extension points have been defined by plug-ins and what extensions are contributed by plug-ins. This information is provided by the platform extension registry, IExtensionRegistry.

Why might a plug-in want to know what extensions are present? A concrete example will help show the need for this information and the protocol for getting it.

Recall the workbench Show View dialog which shows all of the available views that have been installed in the platform.

Show View dialog with Hello entry

We know that the category names and view names of all contributed views are specified in the plugin.xml file for any plug-in that contributes an extension for org.eclipse.ui.views. But how does the workbench find out this information? From the platform extension registry. The following code is a simplified snippet based on the workbench implementation of the Show View dialog:

	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IExtensionPoint point = registry.getExtensionPoint("org.eclipse.ui.views");
	if (point == null) return;
	IExtension[] extensions = point.getExtensions();
	for (int i = 0; i < extensions.length; i++)
		readExtension(extensions[i]);  //get the information about each extension

We see above that the registry can be obtained from the Platform class. The protocol in IExtensionRegistry is used to find the extension point named org.eclipse.ui.views. Information in the registry about particular extension points or extensions can be found using protocol defined in IExtensionRegistry, IExtensionPoint, and IExtension. The javadoc for these classes provides detailed information about the registry protocol.

Once the extension definition of interest has been found, protocol in IConfigurationElement can be used to examine the individual attributes of an extension.