Alexey Romanov
Alexey Romanov

Reputation: 170745

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

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

Upvotes: 2

Views: 633

Answers (3)

Neil Bartlett
Neil Bartlett

Reputation: 23948

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.

Upvotes: 4

BJ Hargrave
BJ Hargrave

Reputation: 9384

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

Upvotes: 0

Robin
Robin

Reputation: 24262

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

Upvotes: 1

Related Questions