Previous Topic

Next Topic

Book Contents

Book Index

Factory and dynamic storage

The Storage on top of java.io is capable of using factory and dynamic storage.

A factory storage keeps an initial set of bundles with their archives, native libraries and data files, which should not be changed by the OSGi framework. In this way, the framework can easily restore its initial state in case of a fault.

Dynamic storage (default) is defined to include data for bundles installed or updated through the OSGi Framework API. As this storage is supposed to keep frequently changing data, it can be placed on a special R/W file system (e.g. RAM or flash).

Benefits from using factory and dynamic storage

How the framework treats bundles from factory storage

The OSGi framework treats bundles included in a factory storage as installed from file as their JARs remain at their original location, and only their manifests and related data files are copied to the framework storage. The factory storage keeps the original locations of its bundles in a file (f.st) so that they can be located at startup. Bundles can be placed in a common directory or in different ones depending on the system requirements.

In addition, if explicitly specified and if the installed bundle JAR file is originally located in a directory called bundles, the bundle's manifest and data files may be saved to the parent directory of the bundles one within a subdirectory, called data, and not be placed in the default framework storage location.

If a bundle changes its data files or is updated through the OSGi Framework API, the changes are written into dynamic storage and thereafter the data from dynamic storage is used. The bundle is not considered as installed from file any more, but as regularly installed one.

Dynamic storage is with higher priority than factory storage – if there is data in both storages for a bundle, the framework will use the one from dynamic storage. If a bundle is uninstalled, its data will be deleted from dynamic storage.

How to install a bundle for factory storage

Factory storage should be explicitly modeled by adding installed from files bundles to the framework, which as a result will produce the appropriate storage structure and content. Installing bundles from factory storage should be done in a special way not defined by the OSGi Framework Specification - at framework runtime through an option of the fw.install command and at framework startup through the startup bundles list file.