Writing the Bundle Activator

To increase flexibility in integrating existing services to an OSGi framework (in general), a service can be accompanied with a bundle activator, which will get temporary control of execution during the bundle start and stop, thus performing the necessary tasks such as registering services.

In this section, we will implement a small bundle activator for our inventory implementation. It will instantiate and register the service on start and then unregister it on stop.

For that, we will create an implementation of the BundleActivator interface (from the OSGi Core API) and declare it as our bundle activator in the POM.

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

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