Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
Markus Kuppe is currently offline Markus Kuppe
Messages: 177
Registered: July 2009
Senior Member
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
Thomas Watson is currently offline Thomas Watson
Messages: 419
Registered: July 2009
Senior Member
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
BJ Hargrave is currently offline BJ Hargrave
Messages: 55
Registered: July 2009
Member
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: Sat Jul 26 03:23:44 EDT 2014

Powered by FUDForum. Page generated in 0.01768 seconds