/** * Returns <code>true</code> if this bundle implements the extension point * with the given <code>extensionPointId</code>. * * @param bundle the bundle to test * @param extensionSimpleId the simple id of the extension point * @param extensionPointId extension id to search for * * @return <code>true</code> if this bundle implements the extension point * with the given <code>extensionPointId</code> */ public static boolean contributesToExtensionPoint(Bundle bundle, String extensionSimpleId, String extensionPointId) { IExtensionRegistry registry = RegistryFactory.getRegistry(); IContributor contributor = ContributorFactoryOSGi.createContributor(bundle); for (IExtension extension : registry.getExtensions(contributor.getName())) { if (extension.getExtensionPointUniqueIdentifier().equals(extensionPointId)) { if (extensionSimpleId != null && !extensionSimpleId.equals(extension.getSimpleIdentifier())) { continue; } return true; } } return false; }
@SuppressWarnings("restriction") @BeforeClass public static void setupExtensions() throws Exception { final IExtensionRegistry registry = Platform.getExtensionRegistry(); Object key = ((ExtensionRegistry) registry).getTemporaryUserToken(); Bundle bundle = Activator.getDefault().getBundle(); IContributor contributor = ContributorFactoryOSGi.createContributor(bundle); InputStream inputStream = null; try { inputStream = FileLocator.openStream(bundle, new Path("datafiles/TestJSConstraintExtension.xml"), false); registry.addContribution(inputStream, contributor, false, null, null, key); } finally { if (inputStream != null) { inputStream.close(); } } // wait until jobs kicked off by adding the contribution are complete DynamicExtensionUtils.waitForJobs(); }
public ProjectTemplateExtensionLoader() { Bundle bundle = Platform.getBundle(ProjectTemplateActivator.PLUGIN_ID); this.contributor = ContributorFactoryOSGi.createContributor(bundle); this.extensionRegistry = (ExtensionRegistry) Platform.getExtensionRegistry(); this.wizardRegistry = NewWizardRegistry.getInstance(); }
public BaseContributionFactory() { super(); registry = RegistryFactory.getRegistry(); key = ((ExtensionRegistry) registry).getTemporaryUserToken(); contributor = ContributorFactoryOSGi.createContributor(getBundle()); }