Hi Luca, Luca Ferrari schrieb: > Hi all, > I'm almost new to OSGi, so apologize me if I'm doing trivial questions. Now, > I'd like to know how OSGi reacts to a bundle that is not polite and does not > use facilities like a service tracker to catch a removed service. In the case > a bundle A holds a reference to a service in the bundle B, and the latter is > uninstalled, what happens? Moreover, the service hold by A is a concrete > reference to the implementation in B or there's a wrapper layer that catches > A-to-B requests and passes them to the B implementation, so hiding the B > implementation?
The OSGi specification has an important section on this matter: Section 5.4, Stale References (p. 116 in the R4.1 Core Specification). It is very important that service consumers release services which are unregistered. At the lowest level, such consumers should implement a ServiceListener to get a notification when the services is unregistered. Instead of implementing the ServiceListener yourself you may also make use of the ServiceTracker class. This is a very interesting and usefull class to help tracking services without requiring to tackle with the nitty gritty details of implementing a ServiceLister. The third option you have is to use Declarative Services as specified in the Compendium. This specification allows for the declaration of service references and managemenent of references by the so called Service Component Runtime. Various other framework also exist to help you with managing service references, for exampl iPojo or DependencyManager (both available from the Apache Felix Project; sorry for the bias, but this is where I come from with respect to OSGi ;-) ) At the end of the day, it all amounts to the service consumer responsibility to let go of a service and its reference when the service is unregistered, which is also the case when the containing bundle is stopped. Hope this helps. Regards Felix _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
