An implementation of the OSGi Preferences service Copyright 2004 TRIALOG Licenses This implementation by Trialog of the OSGi Preferences service is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Installation Loading and starting the bundle in any OSGi framework should be enough to have a Preferences service available. Software Design A good effort was made to provide an exhaustive javadoc, so you should start there. Some words about the backing store The BackingStore class implements storing and retrieving data from the underlying operating system. It uses context.getDataFile() to obtain a file handler from OSGi and the name is formatted like [.]. Format of the file is user readable: - Lines starting with P define the path to the node used for the next definitions. - Lines starting with K define a preferences key. - Lines starting with V provide the preferences value. There are tests to ensure that data of uninstalled bundles (while Preferences is running and also when Preferences is re-started) are removed. Otherwise, data of a bundle are flushed when it is stopped and data of all bundles are also flushed when Preferences stops. There is no optimization of any kind, like for example a "backup flag" to indicate whether flushing is really necessary. In fact, optimizing really depends on your hardware. IMHO, current implementation is quite OK on a PC - as long as you stop properly the framework. What could be missing is to write on-the-fly data to disk, but even then, perhaps you would want a small time-out... As an other example, if you have a hardware with battery backed-up power supply and flash memory, then you maybe have two good reasons not to write too frequently the data to "disk". To conclude, I would say that current implementation takes into account all the standard requirements; and let the administrator of the framework improve the backing store if needed. Test The test folder contains some stuff to validate the behaviour of the Preferences service. com.trialog.osgi.service.prefs.Activator is a single class that provides an OSCAR command shell interface to put and get preferences using a Preferences service. Preferences_Test and PreferencesService_Test classes are JUnit TestCases that can be run to validate the implementation according to the OSGi specification. They have always been run from within Eclipse so there is no ANT script for them.