Check whether a file is an OSGi bundle (and find the bundle name) without installing it in the OSGi framework

寵の児 提交于 2019-12-12 20:01:38

问题


Is it possible? Or do I have to try to install it?


回答1:


I'll assume you're talking about OSGi Release 4, since in OSGi Release 3 and earlier any valid JAR file was also a valid OSGi bundle.

Simply read the JAR's manifest using the standard Java APIs in the java.util.jar package. The minimum headers required to be a valid R4 bundle are:

  • Bundle-ManifestVersion: 2
  • Bundle-SymbolicName: ...

As BJ points out, the "id" of the bundle is assigned when it is installed, but what many people take to be the "id" is actually the Bundle Symbolic Name.




回答2:


You can check for the Bundle-Name, or a host of Bunde-XXX properties within the *meta-inf/manifest.m*f jar file.




回答3:


The bundle id is assigned by the framework when the bundle is installed. Thus only an installed bundle has a bundle id.



来源:https://stackoverflow.com/questions/8431859/check-whether-a-file-is-an-osgi-bundle-and-find-the-bundle-name-without-instal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!