Blueprint No-OSGi

The Blueprint No-OSGi module makes it easy to use OSGi Blueprint as a dependency injection framework outside of OSGi containers such as inside any Servlet Engine.

You can then use Blueprint as a small standards base alternative to the Spring Framework’s XML dependency injection files.

How to use Blueprint No-OSGi

Just create the blueprint container giving the urls of the xml descriptors

BlueprintContainerImpl container = new BlueprintContainerImpl(classLoader, resourcePaths);

You can then access the instantiated beans using the blueprint api

Foo foo = (Foo) container.getComponentInstance("foo");

When you’re done with the container, you need to destroy it



The Blueprint No-OSGi module has limitations due to the fact that OSGi is not available. The use of <reference> and <reference-list> and <service> elements are not supported.

Configuring blueprint through properties

Blueprint beans can be configured using the variable substitutions. You need to declare the ext namespace and add the property placeholder bean in your blueprint xml

<blueprint xmlns=""
        	<ext:property name="myProperty" value="defaultValue" />
	<bean ...>
		<property name="myProperty" value="${myProperty}" />

Default values can be specified by passing a Map<String,String> object at container creation time. Note that the default values for system override (compared to standard blueprint use in OSGi) has been changed so that the properties passed to the container and system properties will override default values.