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 14:27 Go to next message
Markus Kuppe is currently offline Markus KuppeFriend
Messages: 177
Registered: July 2009
Senior Member

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?

Re: Filter cyclic service registrations in EventHook [message #513599 is a reply to message #513544] Wed, 10 February 2010 16:39 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 479
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.


Re: Filter cyclic service registrations in EventHook [message #513632 is a reply to message #513544] Wed, 10 February 2010 17:54 Go to previous message
BJ Hargrave is currently offline BJ HargraveFriend
Messages: 58
Registered: July 2009
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: Sun Apr 22 08:59:51 GMT 2018

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

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