Java Reference
In-Depth Information
disabled —No autodetection of service-interface names is undertaken; the
interface names must be explicitly declared. This is the default mode.
interfaces —The service object is registered using all of its implemented pub-
lic Java interface types, including any interfaces implemented by super classes.
class-hierarchy —The service object is registered using its actual type and any
public supertypes up to the Object class (not included).
all-classes —The service object is registered using its actual type, all public
supertypes up to the Object class (not included), as well as all public interfaces
implemented by the service object and any of its super classes.
A limitation for providing services
Blueprint requires using Java interfaces for services, whereas basic OSGi and Declar-
ative Services allow (but don't recommend) you to use a Java class as a service. You
may wonder why Blueprint requires services to be interfaces. Blueprint injects servic-
es into components using dynamic proxies ( java.lang.reflect.Proxy ), which re-
quire interfaces. We'll discuss Blueprint's use of proxies more later.
After you've described your component and the services it provides in your XML
description, you need some way to tell the Blueprint implementation about it. As with
Declarative Services, Blueprint introduces a new manifest header to reference the
component description file. If you examine the circle bundle's manifest, you see it has
the following entry:
Bundle-Blueprint: OSGI-INF/circle.xml
Following the same approach as Declarative Services, Blueprint employs the extender
pattern and probes bundles to determine if they contain this manifest header. If so,
the Blueprint implementation manages the contained components; if not, the bundle
is ignored.
Fragmented components
The Bundle-Blueprint header can take one of a number of forms:
Absolute path —The path to a resource on the bundle class path. For example:
Bundle-Blueprint: OSGI-INF/circle.xml .
Directory —The path to a directory on the bundle class path. Here, the path must
end in a slash (/). For example: Bundle-Blueprint: OSGI-INF/ .
Pattern —The last component of the path specifies a filename with an optional
wildcard. The part before is the path of the directory in the bundle class path.
For example: Bundle-Blueprint: OSGI-INF/*.xml .
One interesting point to note is that a single logical component can be defined over
many Blueprint XML files. This idea is borrowed from Spring Beans, where it's useful
if you need to switch the behavior of a component in different environments—say, for
local testing versus enterprise deployment.
Search WWH ::




Custom Search