Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322574 - Implement bundle FindHook/EventHook support
Summary: Implement bundle FindHook/EventHook support
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.6   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-12 14:55 EDT by Thomas Watson CLA
Modified: 2010-08-16 10:24 EDT (History)
1 user (show)

See Also:


Attachments
patch (25.67 KB, patch)
2010-08-12 15:06 EDT, Thomas Watson CLA
no flags Details | Diff
Updated patch with composite ShrinkableCollection support (39.71 KB, patch)
2010-08-15 12:02 EDT, BJ Hargrave CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Watson CLA 2010-08-12 14:55:48 EDT
OSGi R4.3 is defining two new hooks related to bundles.
- FindHook which hooks into the BundleContext.getBundles() method
- EventHook which hooks into BundleEvent delivery
Comment 1 Thomas Watson CLA 2010-08-12 15:06:36 EDT
Created attachment 176493 [details]
patch

BJ, please review.

I created a new public method org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHooksPrivileged(ParameterizedRunnable<H>, String, String) to share the code that looks up hook registrations and calls out to them and handling exceptions etc.  This is done by passing a ParameterizedRunnable which is used to make the actual hook call.  This requires inner classes in order to maintain a state for the variables that get passed to the hook methods (poor man's closures).  I worry that this may impact performance since it will create an extra object for each action event/find/listen.  I am hoping one extra object creation is just noise when compared to all the other objects we are creating during these actions.
Comment 2 Thomas Watson CLA 2010-08-13 09:36:53 EDT
Also, I can see a way to call out to bundle EventHooks once for each event (instead once for sync and once for async listeners).  We would need to have a shrinkable collection that wraps the two shrinkable collections representing the collection of async and sync listeners.  Providing a iterator for such a collection that prevents duplicates would be needed.
Comment 3 BJ Hargrave CLA 2010-08-15 12:02:31 EDT
Created attachment 176617 [details]
Updated patch with composite ShrinkableCollection support

Tom, I reviewed the patch and made a number of changes. I replaced the use of ParameterizedRunnable since its use here was not cohesive. I created a HookContext interface to use as the "closure" for calling hooks.

I also updated the ShrinkableCollection type to wrap multiple collections and used that for bundle.EventHook to enable a single call to the hook for both sync and async bundle event listeners.

There are a number of other minor improvements and some improved comments.

I think this is ready for release. Let me know if you want me to release it to HEAD.
Comment 4 BJ Hargrave CLA 2010-08-16 10:24:32 EDT
Released patch to HEAD.