<osgi:bundle id ="greeterServiceBundle"
You can inject into a variable of type org.osgi.framework.Bundle , just as you would any other bean.
More powerful, however, is the prospect of dynamically loading and starting bundles using Spring.
This sidesteps the shell we used earlier to install a service. Now, that configuration is built into your
application and it will be enforced on your application context's startup. To do this, you need to specify
the location of the .jar to be installed, and optionally an action to take, such as start , when the bundle
is installed into the system.
You can specify what action the bundle should take on the event that the OSGi runtime is shut down
using the destroy-action attribute.
12-4. Finding a Specific Service in the OSGi Registry
OSGi will let you maintain multiple versions of a service in your registry at the same time. While it is
possible to ask the registry to simply return all instances of the services that match (that is, by interface),
it can be useful to qualify them when searching.
OSGi, and Spring Dynamic Modules on top of it, provides many tools for discriminating services both in
publishing and consuming services.
Multiple services of the same interface may be registered inside of an OSGi environment, which
necessitates a conflict-resolution process. To aid in that, Spring Dynamic Modules provides a few
features to help.
The first feature is ranking. Ranking, when specified on a service element, allows the ascription of a rank
relative to other beans with the same interface. Ranking is specified on the service element itself. When
encountered, the OSGi runtime will return the service with the highest-ranking integer value. If a version
of a service is published with a higher integer, any references will rebind to that.