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

Hello Thomas,

I tried with that sample as well, as 

String fullPath = RuntimeTestsPlugin.TEST_FILES_ROOT + "registry/elementsByContributor/" + fileName + "/plugin.xml";
		URL urlA = RuntimeTestsPlugin.getContext().getBundle().getEntry(fullPath);
		InputStream is = urlA.openStream();
		IContributor nonBundleContributor = ContributorFactorySimple.createContributor(fileName);
		return registry.addContribution(is, nonBundleContributor, false, urlA.getFile(), null, null);

But still i don't get the elements i register for the extension point when I check it later.

Then I went and checked the XML file in which the input stream is given and there was my error :)

http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/tree/tests/org.eclipse.core.tests.runtime/Plugin_Testing/registry/elementsByContributor/A/plugin.xml

I had not given it as inside <plugin> XML tags. Once I wrapped my extension point XML with <plugin> it worked fine.

Thanks Thomas.


Regards
Awanthika


On Mon, May 9, 2016 at 6:15 PM, Thomas Watson <tjwatson@xxxxxxxxxx> wrote:
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



_______________________________________________
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



--
------------------------------------------------------------------------------------------->>
Awanthika Senarath
Software Engineer
WSO2 Inc,


Back to the top