2.3 Spring DM and Blueprint Concepts

Spring DM is a project which enables services to be published and consumed using descriptions written in XML.

The XML descriptions reside in files with extension .xml in the bundle’s META-INF/spring sub-directory.

To publish a service, an <osgi:service> tag is used, specifying the implementation class of the service and the interface class to be used. Spring DM constructs an instance of the implementation class and publishes that instance in the OSGi service registry under the interface when the bundle is started.

To consume a service, an <osgi:reference> tag is used and the service may be passed into other Spring beans using Spring’s dependency injection facilities.

Spring DM automatically creates proxies for OSGi services so that the actual service object may come and go at runtime. If a service disappears, any proxies to the service will wait for the service to re-appear. This effect is known as damping.

When a bundle is started, Spring DM builds the application contexts specified by the XML descriptions, creates proxies for the specified services, and publishes the specified services to the OSGi service registry.

When a bundle is stopped, Spring DM retracts any services it published on behalf of the bundle and closes the bundle’s application contexts. Virgo turns off damping of a service proxy while the proxy’s application context is being closed.

Spring DM was contributed to Eclipse as the Gemini Blueprint project. Virgo has Gemini Blueprint built-in.

Gemini Blueprint supports both Spring DM and Blueprint programming models. Blueprint, known formally as the "OSGi Blueprint Container", provides some of the basic facilities of Spring DM, including all those just mentioned, but in an OSGi standard form. See Appendix C, Further Reading for the Blueprint specification.