Interface SettingStore
- All Known Implementing Classes:
FileSettingStore
A setting store instance is always associated with the current user session. Any settings being
put into the store (via setAttribute(String, String)
) are considered persisted from that
point on.
To retrieve data stored in a previous session, a client can invoke the method
loadById(String)
with the ID of the session to load into the store. This will load any
data stored under that id into the current setting store.
The framework will assign a new setting store to each new UI session, based on the current
session id. After the user has authenticated, application developers can use the
loadById(String)
method to initialize the store with persisted data stored under that id
during a previous session. Obviously, any data that is set into the store from that point on,
will also be persisted under the current id and will also be available in the future.
Custom setting store implementations are supported, those must provide a corresponding
SettingStoreFactory
.
- Since:
- 2.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSettingStoreListener
(SettingStoreListener listener) Attaches the given listener to this setting store.getAttribute
(String name) Returns the attribute stored under the specified name in this setting store.Returns anEnumeration
of strings with the names of all attributes in this setting store.getId()
Returns the unique identifier of this setting store.void
Replaces the contents of this setting store with the persisted contents associated with the given ID.void
removeAttribute
(String name) Removes the attribute stored under the specified name from this setting store.void
Removes the given listener from this setting store.void
setAttribute
(String name, String value) Stores a given attribute in this setting store, using the name specified.
-
Method Details
-
getAttribute
Returns the attribute stored under the specified name in this setting store.- Parameters:
name
- a non-null String specifying the name of the attribute- Returns:
- the attribute stored under the given name or
null
if no attribute is stored under that name
-
getAttributeNames
Enumeration<String> getAttributeNames()Returns anEnumeration
of strings with the names of all attributes in this setting store.- Returns:
- an enumeration with the attribute names in this setting store, never
null
-
setAttribute
Stores a given attribute in this setting store, using the name specified. If an attribute with the same name is already stored in this setting store, the previous value is replaced. The attribute is considered persisted when after this method completes.If the value is
null
, this has the same effect as callingremoveAttribute(String)
.SettingStoreListener
s attached to this instance will be notified after an attribute has been stored.- Parameters:
name
- the name of the attribute, must not benull
or emptyvalue
- the attribute to store, may benull
- Throws:
IOException
- if the load operation failed to complete normally
-
removeAttribute
Removes the attribute stored under the specified name from this setting store. If no attribute is stored under the specified name, this method does nothing.SettingStoreListener
s attached to this instance will be notified after an attribute has been removed.- Parameters:
name
- the name of the attribute to remove, must not benull
- Throws:
IOException
- if the remove operation failed to complete normally
-
loadById
Replaces the contents of this setting store with the persisted contents associated with the given ID.The attributes of this setting store will remain associated with the old id, but will be removed from this store instance.
SettingStoreListener
s attached to this store will receive a notification for each removed attribute.During the load operation this store will be filled with the attributes associated with the new ID.
SettingStoreListener
s attached to this store will receive a notification for each added attribute.After the load operation this store will only hold attributes associated with the new id value.
- Parameters:
id
- the ID of the settings to load, must not benull
or empty- Throws:
IOException
- if the load operation failed to complete normallyIllegalArgumentException
- if the given id is empty
-
getId
String getId()Returns the unique identifier of this setting store.- Returns:
- a non-empty string, never
null
-
addSettingStoreListener
Attaches the given listener to this setting store. Listeners will be notified of changes in the store. If the listener has already been added to this store, this method does nothing.- Parameters:
listener
- the listener to add, must not benull
-
removeSettingStoreListener
Removes the given listener from this setting store. If the listener has not been added, this method does nothing.- Parameters:
listener
- the listener to remove, must not benull
-