Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Dynamic Contributtions using IExtensionRegistry.addContribution
Dynamic Contributtions using IExtensionRegistry.addContribution [message #773866] Mon, 02 January 2012 18:53 Go to next message
Rafael Ribeiro is currently offline Rafael RibeiroFriend
Messages: 29
Registered: January 2012
Junior Member
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 19:29]

Report message to a moderator

Re: Dynamic Contributtions using IExtensionRegistry.addContribution [message #774727 is a reply to message #773866] Wed, 04 January 2012 13:41 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 Mar 29 05:30:10 GMT 2024

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

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

Back to the top