Java Reference
In-Depth Information
12.1.5
Advanced Blueprint features
The features of Blueprint we've described so far are largely comparable to those of
Declarative Services. But because Blueprint is an evolution of Spring Dynamic Mod-
ules, a lot of experience from that work was carried over into creating the Blueprint
specification. This heritage has resulted in some advanced concepts, such as manager
values, scopes, type converters, and metadata, which we'll discuss in this section.
MANAGER VALUES
If you've developed Spring applications in the past, you likely know it's possible to
define complex object graphs using the Spring XML model. This gives software archi-
tects a number of options when composing applications, because the overall program
structure doesn't need to be hardcoded in Java. This is particularly useful for scenar-
ios such as desktop testing versus enterprise deployment; with just a few tweaks of
XML , you can wire together a raft of new functions without recompiling code.
Blueprint has inherited this ability and supports several constructs in the XML
declaration:
<value> —An object that can be directly constructed from its text string contents.
<ref> —A reference to a top-level manager in the same Blueprint container.
<idref> —The ID of another manager that is checked by the Blueprint con-
tainer. This is the preferred mechanism to pass in a manager ID compared to an
unchecked string value, which would show up later at execution time.
<map> —A java.util.Map containing a sequence of associations between a key
and an object.
<props> —A java.util.Properties containing string keys and values.
<list> —A java.util.List containing other values.
<set> —A java.util.Set containing other unique values.
<array> —A primitive array containing other values.
It's also possible to use the various Blueprint managers we've been discussing inline in
these constructs. Every Blueprint manager has a particular value it provides, similar to
macro expansion. You've already seen this in action in the way reference managers
give access to underlying service references, where the value of a service-reference
manager is either a service object or a ServiceReference to a service object. For com-
pleteness, table 12.2 lists the value objects associated with each Blueprint manager.
Table 12.2
Blueprint manager value objects
Manager
Value
<bean>
The instantiated object created by this bean.
<service>
A proxy object wrapping the service registration created as a result of regis-
tering the service in the OSGi service registry. (A proxy is returned because
the unregister() method isn't supported and throws an exception.)
 
Search WWH ::




Custom Search