I recently received a question about manifest properties… I thought it would be useful to share the question and answer here. The question:
I guess this is more of a philosophical question and probably a lack of personal OSGi knowledge but here goes. Why is the ManifestParseContext the same from manifest to manifest, or at least the properties available the same? If my application loads a manifest at some point later, why is that manifest load subject to all the prior manifest properties? It would seem like very <manifest></manifest> would be “isolated” from others but, that doesn’t appear to be the case.
Here is the explanation I gave:
OSGi does not have a concept of properties like Gravity. This is a Gravity feature.
The properties are actually isolated, just not in the manner that you’re thinking… if I have this in the initial manifest
<manifest xmlns="http://ns.adobe.com/gravity/manifest/1.0"> <bundle location="alice.swf"/> <property name="alpha" value="apple"/> <include location="other-manifest.gxml"/> <property name="delta" value="date"/> <bundle location="carol.swf"/> </manifest>
and other-manifest.gxml contains
<manifest xmlns="http://ns.adobe.com/gravity/manifest/1.0"> <property name="bravo" value="banana"/> <bundle location="bob.swf"/> <property name="bravo" value="blackberry"/> <property name="charlie" value="cranberry"/> </manifest>
then the alpha, bravo (with a value of “blackberry”), charlie, and delta properties are visible for the definition of the carol.swf bundle and for any manifests loaded from the carol.swf bundle. Only the alpha and bravo (with the value of “banana”) properties are visible to the bob.swf bundle, and only those properties will be propagated to any calls to installBundlesFrom* from bob.swf (the bob.swf bundle is isolated from later changes). If installBundlesFrom* is called from alice.swf, none of these properties will be defined for that manifest.
In other words, each bundle captures the properties that were valid at the point of definition of that bundle, and the captured values of those properties are propagated in subsequent calls to installBundlesFrom* from within each bundle. This avoids the need to define properties like debug in every single manifest while providing predictability and traceability. If the properties were simply global it’d be difficult to figure out how a property ended up getting set: it could have happened anywhere, and the ordering of independent loads would be significant.