Preferences API in NetBeans
Preferences API in NetBeans
The Preferences API is java.util.prefs
package provides
convenient way to save and recall preference data. This data should be:
- relatively small (< 8kB),
- accessed only occasionally
- not critical
Design goals of Preferences API
- should work in multithreaded, multiprocess, multilanguage environment
- should work even if backing store isn't available
- back-end indepenent, no explicit saving/loading
- hierarchical, tree-like data store
- store primitive data types as key value pairs
Use cases for Preferences API in NetBeans
- user properties settable via custom options panels
- windows layout configuration
These use cases are currently covered by setting infrastructure which is our way to
store persistent data. Code that utilizes settings infrastructure (like SystemOption,
TopComponent, ServiceType) could be replaced or rewritten by Preferences API.
Use cases for NetBeans specific implementation
We need an implementation that will write to somewhere in the
userdir, rather than globally because not to share a common storage area for
user preferences if someone is running :
- two applications based on NetBeans
- two versions of NetBeans on the same machine
- newer version of a module that writes some setting that an older version can't understand
Preferences API permit, but not require, stored defaults. Applications based
on NetBeans should be able to specify default values which means:
- provide default values for module private settings
- brand, localize default values for the whole application
Almost all user preferences will be probably imported from previous version.
But there might be requirement to:
- ommit import of a subset of the settings