1.2. Migrating Spring-DM to Blueprint


Spring-DM is now deprecated

Spring Dynamic Modules (Spring-DM) is now deprecated and will be removed from a future release of JBoss A-MQ. You can continue to use Spring XML and the Spring framework, however, as long as you do not invoke the Spring-DM component.

Prefer Blueprint over Spring-DM

The Blueprint container is now the preferred framework for instantiating, registering, and referencing OSGi services, because this container has now been adopted as an OSGi standard. This ensures greater portability for your OSGi service definitions in the future.
Spring Dynamic Modules (Spring-DM) provided much of the original impetus for the definition of the Blueprint standard, but should now be regarded as obsolescent. Using the Blueprint container does not prevent you from using the Spring framework: the latest version of Spring is compatible with Blueprint.

How to tell whether your code uses Spring-DM

In Spring XML files, the Spring-DM component is associated with the following XML namespace:
http://www.springframework.org/schema/osgi
To identify the parts of your application that use Spring-DM, search for the preceding namespace string in your code.

How to migrate Spring-DM to Blueprint

If you have a Spring XML file that uses the Spring-DM component, migrate this file to Blueprint XML, as follows:
  1. In the standard Maven project layout, Blueprint XML files are stored under the following directory:
    src/main/resources/OSGI-INF/blueprint
    If it does not already exist, create this directory under your Maven project.
  2. Move the relevant Spring XML file from the Spring directory, src/main/resources/META-INF/spring, to the Blueprint directory, src/main/resources/OSGI-INF/blueprint.
  3. Edit the Spring XML file in order to convert it to a Blueprint XML file. For example, a typical Spring XML file using Spring-DM has the following outline:
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:osgi="http://www.springframework.org/schema/osgi">
        ...
        <osgi:reference id="osgiPlatformTransactionManager"
                        interface="org.springframework.transaction.PlatformTransactionManager"/>
    
        <osgi:reference id="osgiJtaTransactionManager"
                        interface="javax.transaction.TransactionManager"/>
        ...
    </beans>
    You can convert this Spring XML file to a Blueprint XML file by replacing the beans root element by a root blueprint root element, and replacing Spring-DM osgi:reference elements by Blueprint reference elements. For example:
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        ...
        <reference id="osgiPlatformTransactionManager"
                   interface="org.springframework.transaction.PlatformTransactionManager"/>
    
        <reference id="osgiJtaTransactionManager"
                   interface="javax.transaction.TransactionManager"/>
        ...
    </blueprint>
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.