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

Bug 322574

Summary: Implement bundle FindHook/EventHook support
Product: [Eclipse Project] Equinox Reporter: Thomas Watson <tjwatson>
Component: FrameworkAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hargrave
Version: 3.6   
Target Milestone: 3.7 M2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
patch
none
Updated patch with composite ShrinkableCollection support none

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.