Skip to main content



      Home
Home » Eclipse Projects » Equinox » Dynamic Contributtions using IExtensionRegistry.addContribution
Dynamic Contributtions using IExtensionRegistry.addContribution [message #773866] Mon, 02 January 2012 13:53 Go to next message
Eclipse UserFriend
I'm have a class that makes dynamic contributions while my plugin is loading. I've looked at this article (www.ibm.com/developerworks/opensource/library/os-ecl-dynext/?ca=dgr-lnxw07OSGi) for reference. The method that adds the contributions is:

void addExtension(Bundle bundle, String xmlsrc) throws Exception {

		// use Eclipse Dynamic Extension API
		IExtensionRegistry reg = RegistryFactory.getRegistry();

		Object key = ((ExtensionRegistry) reg).getTemporaryUserToken();

		IContributor contributor = ContributorFactoryOSGi.createContributor(bundle);

		ByteArrayInputStream is = new ByteArrayInputStream(xmlsrc.getBytes("UTF-8"));
		
		if (!reg.addContribution(is, contributor, false, null, null, key)) {

			throw new Exception("Error while adding contribution: " + xmlsrc);
		}
	}


The code works fine, and my contributions are added. But since the contributions are added asynchronously, i wanted to know when my contributions were being added, therefore i implemented the IRegistryEventListener interface and did this:

IExtensionRegistry reg = RegistryFactory.getRegistry();
		
reg.addListener(this);


And the event i'm interested is the "added". I've implemented like this:

public void added(IExtension[] extensions) {
		
		if (extensions != null && extensions.length > 0) {
			
			for (IExtension extension : extensions) {
				
				String extId = extension.getUniqueIdentifier();
			}
		}
	}


The code is called, but while debugging the code, I noticed that the all the IExtension objects supplied as argument are a handle and all the important attributes that I need to check return null (On this example the getUniqueIdentifier() returns null). And I'm sure that i provide the extension id, otherwise the IExtensionRegistry.addContribution method would throw an error.

I don't know if this is the desired behavior but it is strange to receive notifications about registry change and not having any idea what did change.

Just for the record, I've tested some variants, but all of them had the same effect:


  • IExtensionRegistry.addRegistryChangeListener
  • ExtensionTracker class.


My machine:
* Windows 7
* Java 1.6.0_25

Eclipse versions tested:
* Eclipse 3.6.2
* Indigo Service Release 1

[Updated on: Mon, 02 January 2012 14:29] by Moderator

Re: Dynamic Contributtions using IExtensionRegistry.addContribution [message #774727 is a reply to message #773866] Wed, 04 January 2012 08:41 Go to previous message
Eclipse UserFriend
What does your extension definition look like? Are you filling in the id attribute?

You can also examine all of the configuration elements? Are the ones there you expect?

PW
Previous Topic:pde build leaves temp folders when using p2.gathering
Next Topic:Why Equinox is not in Juno release p2 ?
Goto Forum:
  


Current Time: Fri Jul 25 01:37:42 EDT 2025

Powered by FUDForum. Page generated in 0.03022 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top