Yes, notifications to ServiceListeners (and therefore ServiceTrackers) should occur synchronously in the thread that caused the registration/unregistration of the service. Because of this it is generally unwise to hold any locks when registering or unregistering a service.
In many cases you should be able to avoid holding a lock and therefore should not have to create a separate thread. Regards Neil On Fri, Feb 13, 2009 at 6:39 PM, Jacques-Olivier Goussard <[email protected]> wrote: > Hi > I just found a deadlock in our code that was the result of the lack of > asynchronicity. When a service is registered in felix, the trackers are > notified in the same thread. Is > it the intended behavior ? > Looks to me that could lead to a very deep stack of invocation, no ? Of > course I can fix this by doing my service regsitration in a separate thread, > but I wanted > to check first with you for input. > Thanks > /jog > Here I paste an exerpt of the stack trace I have: > > at > com.oz.platform.messaging.routing.RoutingManager.handleServiceEvent(RoutingManager.java:592) > > at > com.oz.platform.osgi.ComponentPlatform$ServiceNotifier.addingService(ComponentPlatform.java:244) > > at > org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(ServiceTracker.java:1030) > > at > org.osgi.util.tracker.ServiceTracker$Tracked.track(ServiceTracker.java:1008) > > at > org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:941) > > at > org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:765) > > at > org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:623) > > at > org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:554) > > at > org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3566) > > at org.apache.felix.framework.Felix.access$200(Felix.java:37) > > at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:833) > > at > org.apache.felix.framework.ServiceRegistry.fireServiceChanged(ServiceRegistry.java:559) > > at > org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:75) > > at org.apache.felix.framework.Felix.registerService(Felix.java:2713) > > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:252) > > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:230) > > at > com.oz.platform.osgi.ComponentPlatform.registerService(ComponentPlatform.java:130) > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

