Last modified 2 years ago
Registry
- OSGi Preferences service is embedded in kraken-core since 1.4.0
- depends on apache felix prefs service 1.0.4
- See OSGi Preferences Service by Example for details.
Console Commands
- registry.set [space] [path] [key] [value]
- set string property
- [space] can be "system" or user-defined name.
- registry.setInt [space] [path] [key] [value]
- set integer property
- registry.setLong [space] [path] [key] [value]
- set long property
- registry.setFloat [space] [path] [key] [value]
- set float property
- registry.setDouble [space] [path] [key] [value]
- set double property
- registry.print [space] [path] [key]
- print value of property
- registry.flush [space] [path]
- forces any change of the Preferences object to be saved in the persistent storage
- registry.sync [space] [path]
- reload the content of the Preferences object from the persistent storage; before reloading, all the contents are saved
How to access registry programmatically
- You can get Preferences service reference by OSGi service lookup.
ServiceReference ref = bc.getServiceReference(PreferencesService.class.getName()); PreferencesService preferences = (PreferencesService) bc.getService(ref);
- To access the system root
preferences.getSystemPreferences();
- To access a user root
prefs = preferences.getUserPreferences(space);
- Store and retrieve value in Preferences
public void put(String key, String value); public void putInt(String key, int value); public void putLong(String key, long value); public void putBoolean(String key, boolean value); public void putFloat(String key, float value); public void putDouble(String key, double value); public void putByteArray(String key, byte[] value);
Example
kraken> registry.set system user name qoo set space: system, path:user, key: name, value: foo kraken> registry.print system user name value: foo
