Chapter 4. How it works

Table of Contents

Loading the Bundle Descriptor
Analyzing dependencies
Generating the manifest

This chapter shall quickly show how the OSGi bundle utility works.

Loading the Bundle Descriptor

As the first step, the bundle descriptor is loaded and interpreted.

Example 4.1. The bundle descriptor from the "create1" example in the distribution

<bundle xmlns="http://www.jeremias-maerki.ch/ns/osgi-bundle">
  <name>Example :: Free Space Logging Example</name>
  <symbolic-name>example.freespace</symbolic-name>
  <headers>
    <header name="Bundle-Activator">example.freespace.impl.Activator</header>
  </headers>
  <exports>
    <export>example.freespace</export>
  </exports>
</bundle>

The bundle descriptor will usually be loaded by one of the Ant tasks.

Example 4.2. Excerpt from the Ant build

<project name="example.freespace" default="all">

  [..]
  <!-- Build manifest from bundle descriptor and add additional entries -->
  <bundle-manifest file="${build.classes.dir}/META-INF/MANIFEST.MF"
        classes="${build.classes.dir}"
        descriptor="${basedir}/bundle.xml">
    <attribute name="Bundle-Version" value="${version}"/>
    <attribute name="Bundle-Vendor" value="${implementation.vendor}"/>
    <attribute name="Bundle-DocURL" value="${implementation.url}"/>
    <attribute name="Implementation-Title"
        value="${Name} (${subproject-name})"/>
    <attribute name="Implementation-Version" value="${version}"/>
    <attribute name="Implementation-Vendor"
        value="${implementation.vendor}"/>
    <attribute name="Implementation-URL"
        value="${implementation.url}"/>
  </bundle-manifest>
  
  <!-- Now build the actual bundle. -->
  <jar jarfile="${build.dir}/${subproject-name}.jar"
        filesetmanifest="merge" manifestencoding="UTF-8">
    <fileset dir="${build.classes.dir}"/>
    <metainf dir="${project-root.dir}" includes="LICENSE.txt,NOTICE.txt"/>
  </jar>
  [..]
</project>