Search code examples
eclipseregistryosgiequinox

Can we contribute a new plugin.xml to ExtensionRegistry


I have a some additional xml files(containing standard eclipse extensions) that lie outside the bundle. Is there a way that I could contribute the extns/extnpoints in those files to the platform's extension registry?

I tried

`Platform.getExtensionRegistry.addContribution(..)`

But the method takes a masterToken object, which I dont have access to, and without which it gives me an exception.


Solution

  • You have to use some internal methods. Here is what I do:

        IExtensionRegistry reg = Platform.getExtensionRegistry();
        Object ut = ((ExtensionRegistry)reg).getTemporaryUserToken();
    
        IContributor cont = ContributorFactoryOSGi.createContributor(Platform
                .getBundle(editor.getPluginId()));
    
    
        if (!reg.addContribution(is, cont, false, null, null, ut))
            Util.impossible("Contribution not added due to error"); //$NON-NLS-1$