The Blueprint Container
The Blueprint Container specification defines a dependency injection framework for OSGi and is an OSGi Alliance standard. It provides a simple programming model to create dynamic applications in the OSGi environment.
The Blueprint Container specification deals with the dynamic nature of OSGi, where services can become available and unavailable at any time. The specification also works with plain old Java™ objects (POJOs), so that the same objects can be used inside and outside the OSGi framework. For example, we can write and unit test simple components in a Java Platform, Standard Edition (JSE) environment without needing to know how they are assembled.
Key factors in the Blueprint programming model are the Blueprint XML files that define and describe the assembly of various components. The specification describes how the components are instantiated and wired together to form a module that runs.
This information describes frequently-used aspects of the Blueprint Container. For more detail, see the OSGi Service Platform Release 4 Version 4.2 Enterprise Specification.
Subtopics
- Blueprint bundles
A Blueprint bundle is a bundle containing one or more Blueprint XML files. The Blueprint Container specification uses an extender pattern. An extender bundle monitors the state of bundles in the framework and acts on behalf of those bundles, based on the state of those bundles.
- Blueprint XML
A Blueprint XML file is identified by a top-level blueprint element and contains definitions of component managers such as a bean manager, a service manager, and service reference managers.
- Beans and the Blueprint Container
In the Blueprint programming model, you declare beans by using the bean element. You specify argument elements to provide the arguments used for object construction, and specified property elements to provide the injected properties.
- Services and the Blueprint Container
In the Blueprint programming model, you use a service element to define the registration of a service in the OSGi service registry. Use ref attribute to reference the bean that provides the service object. Use interface attribute to specify the interfaces under which the service is registered.
- References and the Blueprint Container
In the Blueprint programming model, you use the reference element to find services in the service registry, and the reference-list element to find multiple matching services.
- Scopes and the Blueprint Container
In the Blueprint programming model, you use the scope setting to determine whether a bean manager creates single or multiple object instances.
- Object values and the Blueprint Container
The Blueprint Container specification defines XML elements that describe different types of object values and that we can use in manager definitions.
- Object life cycles and the Blueprint Container
In the Blueprint programming model, a bean manager can manage the life cycle of the object that it creates. The bean manager can notify an object after all properties are injected, or when an object instance is destroyed.
- Resource references and the Blueprint Container
Blueprint components can access WebSphere Application Server resource references by using resource reference declarations.
- Dynamism and the Blueprint Container
In the Blueprint programming model, we can use registration listeners or reference listeners so that a bundle can have control when services become available.
- Type converters and the Blueprint Container
During injection, the Blueprint Container converts the XML value elements into value objects that are injected into the manager components. The elements are converted based on the type of the injected property.
- JNDI lookup for blueprint components
If a bundle contains blueprint XML that declares a number of components each with a given ID, those components can be looked up using the JNDI.
Parent topic: OSGi applications
Related tasks
Develop an OSGi application Create a service bundle Create a client bundle
OSGi Service Platform Release 4 Version 4.2 Enterprise Specification
Build OSGi applications with the Blueprint Container specification