Java Reference
In-Depth Information
12-2. How do I get Started Using Spring Dynamic Modules?
You've got a feeling for how OSGi works, what it's capable of, and even how to go about creating a simple
“hello, world!” example. Now, you want to start using Spring to smooth over some of the minutiae of
resource acquisition and to help build more reliable systems in an OSGi environment.
Use Spring Dynamic Modules to provide the integration. Spring Dynamic Modules is a framework on
top of OSGi that works with any OSGi environment. It provides tight integration for Spring dependency
injection in the world of OSGi, which includes support for things like application context discovery,
interface-based service injection, and versioning.
Spring Dynamic Modules is a very powerful API for integration with the OSGi environment. You
need the Spring framework itself, and the Spring OSGi jars, as well. If you're following along using
Maven, the jars can be added by using SpringSource's OSGi bundle repository. This repository exports
the Spring framework jars, as well as those of countless other open source projects, in an OSGi-friendly
format under a Maven/Ivy-friendly repository. For more information on the repositories, see . To get access to them from Maven, add the
repositories to your pom.xml configuration file, at the bottom, before the closing </project> element:
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle
<name>SpringSource Enterprise Bundle Repository - External Bundle
The SpringSource Enterprise Repository provides numerous OSGi-friendly jars files. To see if yours
is already supported, search for it at .
We'll use this infrastructure to rebuild our previous helloworld example, this time relying on Spring
to provide the injection of the service itself and to make writing the client more in line with what we've
come to expect from Spring development. We've already deployed the service, so we don't need to
rework any of that. Let's instead concentrate on a new client bundle.
Let's explore our revised client code. The entirety of the client is one Java class and two Spring XML
application context files. One file has the OSGi-friendly Spring Dynamic Modules namespace imported;
the other is a standard Spring application context.
Search WWH ::

Custom Search