5.2. Bundle State and Service Registration

In the last chapter, we explained that a bundle usually registers a service when it is started, and it unregisters the service when it is stopped. It is important to realize whether the service registered coincides with the bundle being activated, but this coincidence is not required.

On the one hand, it is perfectly legal for a bundle to be active without having registered its services, or to register them some time after it is first started. It is also permissible that an active bundle unregisters services at any time, even if it is not going to be stopped in the foreseeable future.

On the other hand, when a client bundle has been successfully resolved (that is, its Import-Package declaration has been satisfied by some exporter in the framework), it may not necessarily be able to obtain the services it needs. This is because although the service-providing bundle has exported the package, it may not have registered the service yet.

For the client bundle, to monitor and handle the service events is the only means that can be used to deal with this uncertainty.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.34.62