How is the OSGi bundle start level defined?
I am using Apache felix and would like to persist the start level across framework executions. I do not anticipate a need to change the start level of a bundle very frequently at all an an entry in Manifest.MF seems the most sensible. I've to org.osgi.framework.startlevel but have not seen a practical example.
I am also using maven with the maven-bundle-plugin, if there is an elegant way to incorporate the start level in the POM that would be brilliant.
Bundles don't define their own start level at build-time; the administrator or agent that installs the bundle into the framework defines it.
The core framework defines a Start Level interface in section 8. Quoting:
The Start Level API provides the following functions:
Controls the beginning start level of the OSGi Framework.
Is used to modify the active start level of the Framework.
Can be used to assign a specific start level to a bundle.
Can set the initial start level for newly installed bundles.
The last two are relevant to your inquiry here. Section 8.3.4—Changing a Bundle's Start Level—indicates that the framework will store an assigned start level persistently.
If you're using Apache Felix, there are several ways you can install bundles and assign their start level, whether explicitly or by allowing them to inherit a default start level for installed bundles:
felix.fileinstall.start.level
property, though it's not per-bundle)felix.auto.install.<n>
property)bundlelevel
command)Also, see the felix.startlevel.bundle
property, which controls bundles installed through means other than those above.
As for setting a manifest property (such as with Maven at build time), there used to be a way to do this in Equinox—now deprecated—but there is no standard means for a bundle to indicate to the framework what its proper start level should be.