Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 379710

Summary: Listener support for a "loaded"/"loading" event in the Pluginregistry
Product: [ECD] Orion Reporter: Simon Kaegi <simon_kaegi>
Component: ClientAssignee: Mark Macdonald <mamacdon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: mamacdon
Version: 0.5   
Target Milestone: 0.5 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Simon Kaegi CLA 2012-05-16 11:57:43 EDT
The plugin registry supports the concept of lazy loading for services however in some use cases we need to pre-setup some of the service behavior. When lazy loading a plugin the "load" event provides an opportunity for things like configuration or event hookup to act prior to having the service receive the actual call.
Comment 1 Mark Macdonald CLA 2012-05-25 02:02:43 EDT
Here is a patch that adds a 'lazyLoading' event, which fires after a plugin's iframe has been created but before the lazy service call happens. Listeners for this event can provide a 'before' promise, in which case the registry waits for the promise to resolve before continuing with the lazy service call.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?h=config&id=64bc828f81e47345ffabd3119e0933ef571dbc70
Comment 2 Mark Macdonald CLA 2012-06-01 19:32:23 EDT
OK, I updated the patch. It no longer allows a 'lazyLoading' listener to provide an async task, so there's no risk of halting the plugin load by waiting on a dead promise. LazyLoading listeners are invoked synchronously.

The lazyLoading event fires once for a plugin. A lazyLoading listener is allowed to invoke a service method (say 'B()') of the plugin that is currently lazy-loading. In this case, we have a recursive call to the function at line 55 of pluginregistry.js. 

The recursive call finds _firedLazyLoading == true, so the recursive call gets its hands on the Plugin's _load() promise before the call higher-up on the stack.

As a result, the listener's injected service call 'B()' should always appear on the _load() queue preceding the original service call 'A()' that triggered the lazy load.

The new patch is here:
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?h=config&id=40941f19421c2dad3adce036b62cb440b303b430
Comment 3 Mark Macdonald CLA 2012-06-06 12:10:41 EDT
The event is now called 'pluginLoaded' and it is dispatched after every load (both lazy and non-lazy).

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?h=config&id=17580012811a24732250d7a7282a6248aaa6b17b