Spring DM is a project which enables services to be published and consumed using descriptions written in XML. dm Server has Spring DM built-in.
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 like any other
Spring bean and then 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. dm Server turns off damping of a service proxy while the proxy’s application context is being closed.