问题
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: 2Bundle-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