Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This simply creates a map to hold configuration properties where the keys are strings and lookups are case insensitive. Now some configuration properties can be set:

Code Block
        configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
            "org.osgi.framework; version=1.3.0," +
            "org.osgi.service.packageadmin; version=1.2.0," +
            "org.osgi.service.startlevel; version=1.0.0," +
            "org.osgi.service.url; version=1.0.0");

The This sets the Constants.FRAMEWORK_SYSTEMPACKAGES configuration property (string value "org.osgi.framework.system.packages"), which specifies which the class path packages the system bundle should export; this is how classes on the class path are made available to bundles that import them. This example only exports the core OSGi API packages, but other JRE packages could also be added, such as javax.swing. For example, the default Felix launcher defines properties for all packages in various JRE versions (e.g., 1.3.x, 1.4.x, 1.5.x) and appends them to this property using property substitution.

Code Block
        configMap.put(FelixConstants.AUTO_START_PROP + ".1",
            "file:bundle/org.apache.felix.shell-0.8.0-SNAPSHOT.jar " +
            "file:bundle/org.apache.felix.shell.tui-0.8.0-SNAPSHOT.jar");

The This sets the FelixConstants.AUTO_START_PROP configuration property (string value "felix.auto.start"), which is a space-delimited list of bundle URLs that the framework will automatically install and start when the framework starts. This However, this property key cannot be used as is, however, ; it must be appended with a "." and then a number, where the number represents the start level for the bundle when it is installed. In this particular example, ".1" is appended to the property name, thus the two bundles will be installed into start level one. This example uses relative file: URLs, which will load the bundles from the bundle/ directory assuming that the launcher is started from the root directory of the launcher project. It is also possible to specify absolute URLs or remote URLs.

Code Block
        configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");

This sets the last configuration property, BundleCache.CACHE_PROFILE_DIR_PROP (string value "felix.cache.profiledir"), which is a string that specifies the precise directory to be used as the bundle cache profile directory; the Felix bundle cache supports other properties to configure its behavior, but those are not covered here. In this example, the bundle cache profile directory is specified as a relative directory called "cache". Assuming that the launcher is executed from the root directory of the launcher project, then the bundle cache profile directory will be created in the root directory of the project.

...