开发者

Modifying a Bundle Manifest at run time

开发者 https://www.devze.com 2023-04-03 22:11 出处:网络
Is it possible (and if so, safe) to modify the MANIFEST of a bundle anytime during it\'s lifecycle (i.e. presumably only between INSTALLED and RESOLVED).

Is it possible (and if so, safe) to modify the MANIFEST of a bundle anytime during it's lifecycle (i.e. presumably only between INSTALLED and RESOLVED).

I guess another way to ask the question would be,

After INSTALLED, but before RESOLVED, is the MANIFEST already fully evaluated (i.e. further changes would be ignored) making it too late to change?

If all of the above seems absurd.. then my next question would be, does anyone think that it's possible (without nasty framework hacks) to wrap the MANIFEST resolution (i.e. the classloader step to get the META-INF/MANIFEST.MF from a bundle) with a custom impl.

Background: Consider an existing modularity framework, not based on OSGi, that I'd like to simplify the migration for, toward OSGi, by offering the ability to deploy the tone of existing "plugins" without modification, and at开发者_高级运维 runtime, perform an analysis (the "plugins" are well defined so the mapping should not be hard) which converts them to true OSGi bundles, using BND runtime operations to generate a MANIFEST which would be used in place of the potentially none-existent or non-osgi-bundle MANIFEST.

Hopefully that makes sense (@njbartlett!)


Why not define a URL scheme that mutates the manifest as part of the install/update process? When the framework accesses the bundle via your URLConnection, you can return a mutated bundle with the mutated manifest. This is basically what the web bundle support does and it should work for you too.


No you can't do this. The whole JAR file (and therefore the MANIFEST.MF) is read during the install operation. In order to change anything in that JAR you would have to either update the bundle or uninstall and install again.

Regarding what you actually want to do, why can't you just perform the analysis and transformation through bnd before installing the JAR as a bundle?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号