Skip to main content



      Home
Home » Eclipse Projects » Equinox » Filter cyclic service registrations in EventHook
Filter cyclic service registrations in EventHook [message #513544] Wed, 10 February 2010 09:27 Go to next message
Eclipse UserFriend
Hi,

what is the intended way to filter cyclic
org.osgi.framework.BundleContext.registerService(String, Object,
Dictionary) calls in an EventHook?

E.g. an Eventhook listens for "foo" services and upon services
registration creates a modified version of the original service and
registers it with the framework, again as a "foo" service. Obviously
this causes the hook to be notified by the framework again about the new
"foo" services.

Do I need to use marker properties to prevent the EventHook from running
into a cycle?

Thanks
Markus
Re: Filter cyclic service registrations in EventHook [message #513599 is a reply to message #513544] Wed, 10 February 2010 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Marker properties could be used or you could set a thread local variable since the hook should be called synchronously. Then check the thread local variable to see if the Event is a result of the registration of foo by your hook.

Actually now that I think about it Thread local variables may not be the most framework agnostic way to do this. While the events must be fired to all the listeners before returning from registration I don't think the specification forces an implementation to do that all on the same thread as the service registering thread (Equinox uses the registering thread to dispatch the events to the listeners/hooks). So I would go with some service property in this case.

HTH

Tom.
Re: Filter cyclic service registrations in EventHook [message #513632 is a reply to message #513544] Wed, 10 February 2010 12:54 Go to previous message
Eclipse UserFriend
You need to handle this as a hook author. The hooks are very low level API and thus don't provide any filtering support. A marker service property is probably your best bet to identify services which are registered by your hook implementation.
Previous Topic:obtaining a reference to EventAdmin too complex
Next Topic:One Handler for multiple MenutItem
Goto Forum:
  


Current Time: Thu Jul 24 19:36:08 EDT 2025

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

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

Back to the top