Part VI. Spring dm Server

This section is on developing with the Spring dm Server and OSGi based development.

OSGi (Open Services Gateway interface) is a specification maintained by the OSGi Alliance. It was founded in March 1999. One of the goals of OSGi is to reduce complexity by having much better modularity and deployment of libraries and services. The increased modularity primarily comes from a much more fine grained classloading mechanism compared to a standard JVM or Java EE container. Libraries and packages needed at runtime must be explicitly defined and even the version or version ranges required can be specified. Also, what interfaces or classes your library exports are also clearly defined. A library (JAR archive) in OSGi terminology is referred to as a bundle.

There are a few different open source OSGi runtime environments. Some are Apache Felix, Knopflerfish, and Equinox. You may know Equinox as being what the Eclipse IDE is built on. Any Eclipse plugin is actually an OSGi bundle, so Eclipse has very good OSGi development support.

The Spring dm Server is also an OSGi server and is actually built on top of Equinox. Although many customizations and enhancements have been done to make it easier to manage and deploy bundles. Some of the enhancements are customizations to make it easier to deploy Spring bundles and also for deploying web bundles. In fact, standard WARs can be deployed as they are to any web container. Web modules can also be deployed as a thin WAR that uses OSGi imports to resolve any JARs instead of having them embedded in /WEB-INF/lib and also a more OSGi like web solution which will be shown in the next basic example.

SpringSource has made a very nice plugin for developing OSGi bundles and working with the Spring dm Server on the Eclipse IDE. The plugin provides project templates for a basic bundle and also a type called PAR. A PAR is a way to group together related bundles and deploy them together. The plugin also has Server support in the IDE that allows deploying projects to the server. As changes are made to your project, it will automatically keep deploying any changes to the bundle to the server. Also, when managing the project any OSGi bundle from the SpringSource can be downloaded directly into the Spring dm Server.

If you haven't already installed the IDE support for this and would like to run the examples, please refer to the Setup Appendix.