views:

382

answers:

3

i am new to OSGi standard. i want to know more about the structure of bundle package file.

  1. find there is this OSGi-INF folder, the specification mentioned about l10n and permission, i wonder where defined the use of OSGI-INF folder? can i put other stuff into it?
  2. where to store the jar files referenced by the bundle?
  3. besides OSGi-INF and OSGi-OPT is there any folders defined by OSGi standard?

thank you very much.

+1  A: 

The only OSGi bundle element which is mandatory is the bundle specific entries in the META-INF/MANIFEST.MF file.

The OSGi-INF and OSGi-OPT are both optional.

Have a look at this for an overview of what makes an OSGi bundle: http://swik.net/Spring/Interface21+Team+Blog/Creating+OSGi+bundles/

and this describes how DS (Declarative Services) make use of the OSGi-INF folder: http://www.eclipsezone.com/eclipse/forums/t97690.html

James Carr
A: 

OSGi bundle no different from a plain JAR file except for a few mandatory entries in the JAR manifest, the META-INF/MANIFEST.MF file (as already pointed out by James).

All other files and directories are just conventions and best practices like for example folders META-INF/spring or META-INF/maven used by Spring and Maven respectively.

Some OSGi services define similar conventions regarding the use of OSGI-INF directory. As far as I know, there is no single place in specification where all this convention are listed. You can open the specs and search for "OSGI-INF" to find all occurrences :-) Don't worry there is not too many of them.

Pavol Juhos
A: 

You might have a look at the OSGi Core specification. You can download it from the OSGi Alliances website (It is actually quite readable). For example, for version 4.2 of the spec, chapter 3.2 discuses bundles and their structure in detail. As already mentioned in another answer, bundles are actually plain jar files with a Manifest that contains a couple of special manifest headers.

Some of these headers also let you specify the location of some of the files, e.g. in section 3.2.1.11 the Bundle-Localization header is defined:

The Bundle-Localization header contains the location in the bundle where localization files can be found. The default value is OSGI-INF/l10n/bundle. Translations are by default therefore OSGI-INF/l10n/bundle_de.properties, OSGI-INF/l10n/bundle_nl.properties, etc

akr