Relative to the root of the bundle JAR file, the standard location for blueprint configuration files is the following directory:
OSGI-INF/blueprint
Any files with the suffix, .xml
, under this directory are
interpreted as blueprint configuration files; in other words, any files that
match the pattern, OSGI-INF/blueprint/*.xml
.
In the context of a Maven project, ProjectDir
, the
standard location for blueprint configuration files is the following
directory:
ProjectDir
/src/main/resources/OSGI-INF/blueprint
Blueprint configuration elements are associated with the following XML namespace:
http://www.osgi.org/xmlns/blueprint/v1.0.0
The root element for blueprint configuration is blueprint
, so a
blueprint XML configuration file normally has the following outline form:
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> ... </blueprint>
![]() | Note |
---|---|
In the |
There are a few aspects of blueprint configuration that are controlled by
headers in the JAR's manifest file, META-INF/MANIFEST.MF
, as
follows:
If you need to place your blueprint configuration files in a non-standard
location (that is, somewhere other than OSGI-INF/blueprint/*.xml
),
you can specify a comma-separated list of alternative locations in the
Bundle-Blueprint
header in the manifest file—for
example:
Bundle-Blueprint: lib/account.xml, security.bp, cnf/*.xml
Dependencies on an OSGi service are mandatory by default (although this can be
changed by setting the availability
attribute to
optional
on a reference
element or a
reference-list
element). Declaring a dependency to be mandatory
means that the bundle cannot function properly without that dependency and the
dependency must be available at all times.
Normally, while a blueprint container is initializing, it passes through a
grace period, during which time it attempts to
resolve all mandatory dependencies. If the mandatory dependencies cannot be
resolved in this time (the default timeout is 5 minutes), container
initialization is aborted and the bundle is not started. The following settings
can be appended to the Bundle-SymbolicName
manifest header to
configure the grace period:
blueprint.graceperiod
If
true
(the default), the grace period is enabled and the blueprint container waits for mandatory dependencies to be resolved during initialization; iffalse
, the grace period is skipped and the container does not check whether the mandatory dependencies are resolved.blueprint.timeout
Specifies the grace period timeout in milliseconds. The default is 300000 (5 minutes).
For example, to enable a grace period of 10 seconds, you could define the
following Bundle-SymbolicName
header in the manifest file:
Bundle-SymbolicName: org.fusesource.example.osgi-client; blueprint.graceperiod:=true; blueprint.timeout:= 10000
The value of the Bundle-SymbolicName
header is a semi-colon
separated list, where the first item is the actual bundle symbolic name, the
second item, blueprint.graceperiod:=true
, enables the grace period
and the third item, blueprint.timeout:= 10000
, specifies a 10
second timeout.