Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] Registering Extensions dynamically to eclipse extension registry

I have not really used the dynamic contributions stuff in the extension registry.  But I do know there is a testcase that "tests" it at:

http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/tree/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/registry/ContributorsTest.java

Perhaps having a look at that may help.  I'm fairly certain you should not be using reflection to do this.

Tom





From:        Awanthika Senarath <wnthksnrth@xxxxxxxxx>
To:        eclipse-dev@xxxxxxxxxxx
Date:        05/09/2016 07:33 AM
Subject:        [eclipse-dev] Registering Extensions dynamically to eclipse        extension registry
Sent by:        eclipse-dev-bounces@xxxxxxxxxxx




Hello devs,

Im trying to do subject as follows,

InputStream inputStream = generateInputStream(displayName, bundle);
String bundleIdStr = String.valueOf(bundle.getBundleId());
String bundleName = bundle.getSymbolicName();
IContributor contributor = new RegistryContributor(bundleIdStr, bundleName, null, null);
@SuppressWarnings("restriction")
ExtensionRegistry extensionRegistry = (ExtensionRegistry) Platform.getExtensionRegistry();

@SuppressWarnings("restriction")
Field declaredField = ExtensionRegistry.class.getDeclaredField("masterToken");
declaredField.setAccessible(true);
Object masterToken = declaredField.get(extensionRegistry);

@SuppressWarnings("restriction")
boolean addContribution = extensionRegistry.addContribution(inputStream, ContributorFactoryOSGi.createContributor(bundle42), false,
null, null, masterToken);

The method "extensionRegistry.addContribution" return true, but when I iterate over the registered items for the particular
extensions point after this method, I'm unable to find this registration I did dynamically.

If it returns true does not that mean that the dynamic registration was successful?
Why am I not able to see it in the ExtensionRegistry?

Appreciate your feedback..

--
------------------------------------------------------------------------------------------->>
Awanthika Senarath

Software Engineer
WSO2 Inc,
_______________________________________________
eclipse-dev mailing list
eclipse-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipse-dev



Back to the top