Bug 349924 - [api] provide extension point for task activation listeners
Summary: [api] provide extension point for task activation listeners
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: All Windows 7
: P3 enhancement (vote)
Target Milestone: 3.7   Edit
Assignee: Manuel Doninger CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, contributed, noteworthy, plan
Depends on:
Blocks:
 
Reported: 2011-06-21 06:08 EDT by Manuel Doninger CLA
Modified: 2011-10-17 03:32 EDT (History)
3 users (show)

See Also:


Attachments
Patch for extension point (6.76 KB, patch)
2011-06-21 06:09 EDT, Manuel Doninger CLA
no flags Details | Diff
mylyn/context/zip (3.91 KB, application/octet-stream)
2011-06-21 06:09 EDT, Manuel Doninger CLA
no flags Details
Added tests, iterate over all configuration elements (13.34 KB, patch)
2011-08-03 17:01 EDT, Manuel Doninger CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Doninger CLA 2011-06-21 06:08:04 EDT
This patch provides a new extension point to register task activation listeners. This enables plugins to register their listeners without the need to start the plugin itself, which would be necessary with programmatic registering.
Comment 1 Manuel Doninger CLA 2011-06-21 06:09:43 EDT
Created attachment 198316 [details]
Patch for extension point
Comment 2 Manuel Doninger CLA 2011-06-21 06:09:48 EDT
Created attachment 198317 [details]
mylyn/context/zip
Comment 3 Steffen Pingel CLA 2011-07-27 18:45:51 EDT
Thanks for the patch! The proposed change looks good. I have a few minor suggestions for improvement:

* Construct listeners lazily, i.e. on the first event.
* Iterate over all IConfigurationElement objects.

Would you be able to iterate on this?
Comment 4 Manuel Doninger CLA 2011-07-27 18:54:53 EDT
I'll look into this.
Comment 5 Benjamin Muskalla CLA 2011-07-28 08:20:37 EDT
Yep, looks good. Minor comments from my side:

* I'd also add a test for this, should not be too hard to provide a simple mock extension in the tests bundle and ensure it is called.

* Extracting @ITasksCoreConstants.ID_PLUGIN + ".taskActivationListeners"@ should also go into a constant
Comment 6 Manuel Doninger CLA 2011-08-03 05:50:51 EDT
(In reply to comment #3)
> * Iterate over all IConfigurationElement objects.

One question here: Is there a specific reason to iterate over all objects? Wouldn't that have a lower performance? Or doesn't the implementation of getConfigurationElementsFor guarantee, that i get really all configuration elements for an extension point?
Comment 7 Benjamin Muskalla CLA 2011-08-03 05:54:19 EDT
> One question here: Is there a specific reason to iterate over all objects?
Equinox gives no guarantee about the order extensions are listed. Only adding the first one may work in your config but as soon as another extension comes along, it may break yours. Thus we should read all extensions and add all available listeners.
I don't see a performance degradation in this case once you do it lazily.
Comment 8 Manuel Doninger CLA 2011-08-03 17:01:46 EDT
Created attachment 200857 [details]
Added tests, iterate over all configuration elements

Tests added, iterate over all configuration elements, extracted string to constant, initialize listeners on first task activation or deactivation.
Comment 9 Steffen Pingel CLA 2011-08-22 20:50:17 EDT
Thanks a lot for the updated patch! 

I have applied it with a few minor modifications: 
* I renamed the schema attribute from "listenerClass" to "class"
* I guarded the creation of extensions with a catch Throwable. Not pretty but some extensions have the bad habit of throwing LinkageErrors which would propagate otherwise.
* Moved the constant to TaskActivityManager
* The test stub is now an inner class and test cases are separate