public class TLcyPersistentPreferencesAddOn extends ALcyAddOn
ILcyLucyEnv.getPreferencesManager().getCurrentUserPreferences()
. The Lucy
system preferences are retrieved using ILcyLucyEnv.getPreferencesManager().getSystemPreferences()
.
When the
addon is plugged, it reads the preferences from the persistent store. For user properties that are
not available in the persistent store, the properties in the property file defined in the config
file of this addon is used as a fallback (default_preferences.cfg). Only properties that have
values that differ from these defaults are stored persistently. There are no default for system
properties.
Preferences are stored per version. This means that each version of Lucy has its own distinct
set of preferences. Patch versions (like 8.2.1) don't get their own set of preferences but reuse those
of the main version (i.e. 8.2). When Lucy starts, it checks if there already exist preferences for the current
version. If not, the preferences from the newest Lucy version that can be found and that is older than
the current one are imported and copied to the current version.
Where the preferences are stored depends on your operating system.
On Windows, they are stored in the registry
HKEY_CURRENT_USER/Software/JavaSoft/Prefs
HKEY_LOCAL_MACHINE/Software/JavaSoft/Prefs
~/.java
and for Mac ~/Library/Preferences
/etc/.java
and for Mac /Library/Preferences
TLcyPreferencesManager.getCurrentUserPreferences()
object is stored
using the Java 1.4 java.util.prefs.Preferences
API. This also brings the limitations
of that API: java.util.prefs.Preferences
API hierarchical keys are split by a
slash (/), but for consistency with other applications of the TLcyStringProperties
object
within Lucy, we've chosen to use dot (.) as a separator. Therefore dots and slashes are swapped
before the keys are stored in the java.util.prefs.Preferences
API.
For convenience, these methods are offered to manipulate the persistent store: clearUserPreferences()
encodeUserPreferences()
decodeUserPreferences()
clearSystemPreferences()
encodeSystemPreferences()
decodeSystemPreferences()
setClassTraceOn(boolean)
. It prints out which properties are loaded and stored, when they
are loaded and stored, ...
If a custom application is built on top of Lucy, it could be useful to avoid that the standard
Lucy application interacts with the preferences of the custom application. Therefore a prefix
is used to store all preferences. This prefix can be configured by modifying the property
'TLcyPersistentPreferencesAddOn.storagePrefix' in the configuration file of this addon.
If needed, this addon can be replaced by a custom addon that makes the preferences persistent
using some other mechanism. For example one could write an addon that saves the preferences to a
server.
Constructor and Description |
---|
TLcyPersistentPreferencesAddOn() |
Modifier and Type | Method and Description |
---|---|
void |
clearSystemPreferences()
Clears all system preferences.
|
void |
clearUserPreferences()
Clears all user preferences for the current user.
|
void |
decodeSystemPreferences()
Decodes the system preferences from the persistent store into
TLcyPreferencesManager.getSystemPreferences() . |
void |
decodeUserPreferences()
Decodes the user preferences from the persistent store into
TLcyPreferencesManager.getCurrentUserPreferences() . |
void |
encodeSystemPreferences()
Encodes the system preferences (
TLcyPreferencesManager.getSystemPreferences() )
to the persistent store. |
void |
encodeUserPreferences()
Encodes the user preferences (
TLcyPreferencesManager.getCurrentUserPreferences() )
to the persistent store. |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
plugInto(ILcyLucyEnv aLucyEnv)
Plugs this addon into the given lucy environment.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
unplugFrom(ILcyLucyEnv aLucyEnv)
Unplugs this addon from the given Lucy environment.
|
getConfigSourceName, getDisplayName, setConfigSourceName, setDisplayName
@Deprecated public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.@Deprecated public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.aTraceOn
- if true then all log messages are recorded for this
instance. If false, then only the informative, warning and
error log messages are recorded.@Deprecated public boolean isTraceOn()
true
if tracing is enabled for this class.public void plugInto(ILcyLucyEnv aLucyEnv)
ALcyAddOn
plugInto
in class ALcyAddOn
aLucyEnv
- The lucy environment to plug into.ALcyAddOn.unplugFrom(com.luciad.lucy.ILcyLucyEnv)
public void unplugFrom(ILcyLucyEnv aLucyEnv)
ALcyAddOn
unplugFrom
in class ALcyAddOn
aLucyEnv
- The lucy environment to unplug from.ALcyAddOn.plugInto(com.luciad.lucy.ILcyLucyEnv)
public void clearUserPreferences()
public void clearSystemPreferences()
public void encodeUserPreferences()
TLcyPreferencesManager.getCurrentUserPreferences()
)
to the persistent store. This method is automatically invoked when Lucy is exited.public void encodeSystemPreferences()
TLcyPreferencesManager.getSystemPreferences()
)
to the persistent store. This method is automatically invoked when Lucy is exited.public void decodeSystemPreferences()
TLcyPreferencesManager.getSystemPreferences()
. This method is automatically
invoked when the addon is plugged.public void decodeUserPreferences()
TLcyPreferencesManager.getCurrentUserPreferences()
. This method is automatically
invoked when the addon is plugged.