An OSGi runtime consists of a set of bundles running in a managed environment. These bundles provide classes and resources, a (sub)set of which can be exported to other bundles. Each bundle has its own class space (provided by its own ClassLoader
instance) that permits the dependencies and exports to be wired up appropriately.
OSGi also has the ability to manage fragment bundles or simply fragments. These are like bundles that don't have their own life cycle, but can still contribute classes and package dependencies to a host bundle at runtime.
The difference between a fragment bundle and a host bundle is the existence of the Fragment-Host header, which specifies the Bundle-SymbolicName
and, optionally, the bundle-version
attribute of the bundle to attach to. All other OSGi headers are valid for fragments, except for Bundle-Activator
. The reason why the activator is not valid is that fragments do not have their own life cycle; they share the life cycle of their parent...