I am building an Eclipse plug-in that provides a set of core features in the regular plug-in project. The optional features I am providing via fragment projects. But I need the fragments to register themselves with the main plug-in on start-up.
I cannot have a Bundle-Activator in the fragment project. So I am wondering is there some alternate mechanism to declare an entry point or some call-back that I can hook?
And if there is no alternative other than converting the fragment project to a regular plug-in project is there a downside that I need to be aware of?
This is the solution I used based on the accepted answer:
final IExtensionRegistry registry = Platform.getExtensionRegistry(); final IExtensionPoint extensionPoint = registry.getExtensionPoint('myextensionid'); final IExtension[] extensions = extensionPoint.getExtensions(); for (int j = 0; j < extensions.length; ++j) { final IConfigurationElement[] points = extensions[j].getConfigurationElements(); for (int i = 0; i < points.length; ++i) { if ('myelementname'.equals(points[i].getName())) { try { final Object objImpl= points[i].createExecutableExtension('class'); objImplList.add(provider); } catch (CoreException e) { } } } }
You could define an extension point and lookup/call your fragment classes via extensions.
EDIT:
You shouldn’t have to. For example, in my test code, I have the following files in the host plugin:
META-INF/MANIFEST.MF:
plugin.xml:
The fragment contains these files:
META-INF/MANIFEST.MF:
fragment.xml:
These projects were generated using Eclipse 3.3.1.1.