Registering services imperatively in the
start method of an
Activator class is one way of installing services in an OSGi framework. However, it requires that the bundle be started, which in turn requires that either the bundle is started automatically or has classes (such as API classes) accessed by default. Both approaches will mean that additional code will have to be run to bring the system into the desired state.
An alternative is to use one of the declarative service approaches, which represents the service definition in an external file. These are processed using an extender pattern, which looks out for bundles with a given file or files and then instantiates the service from this definition. It combines ...