System Bundle
From OSGi Community Wiki
The system bundle is a special bundle that represents the OSGi framework itself, from within that framework. It has the following roles:
- Exports packages from the JRE (excluding
java.*), for examplejavax.swing,org.w3c.cometc. - Exports the OSGi framework packages such as
org.osgi.framework. - Stopping the system bundle has the effect of shutting down the OSGi framework.
- Updating the system bundle has the effect of restarting the OSGi framework (requires support from the launcher).
The system bundle always has a bundle id of 0 (zero), so in code we can safely obtain a reference to it as follows:
Bundle systemBundle = context.getBundle(0);
Symbolic Name
The Bundle Symbolic Name of the system bundle depends on the specific framework we are running, but it has an alias that is always system.bundle. This can be used to refer to it from the manifest of another bundle, for example:
-
Require-Bundle: system.bundleimports all of the packages exported by the system bundle -
Fragment-Host: system.bundledefines a fragment of the system bundle.
Using this alias is usually preferable since we can avoid depending on a specific framework implementation.