org.eclipse.rwt.service
Interface ISettingStore
-
All Known Implementing Classes:
-
FileSettingStore
- public interface ISettingStore
An ISettingStore is a mechanism persisting settings (i.e. key/value
pairs) beyond the scope of a single session.
A setting store instance is always associated with the current 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, client can invoke
the
loadById(String)
method with an appropriate id
.
This will load any data stored under that id into the current setting store.
This mechanism is intented to be used as follows: by default RWT will assign
a new setting store to each new 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.
Clients who wish to implement own setting store must
also provide a corresponding
ISettingStoreFactory
.
-
Since:
- 1.1
-
See Also:
-
FileSettingStore
getAttribute
public
String getAttribute(
String name)
- Returns the attribute stored under the specified name in this
ISettingStore
, or null
if no attribute is stored under
that name.
-
-
Parameters:
-
name
- a non-null String specifying the name of the attribute
-
Returns:
- a String value or
null
getAttributeNames
public
Enumeration getAttributeNames()
- Returns an
Enumeration
of String objects with the names
of all attributes in this
ISettingStore
.
-
-
Returns:
- an
Enumeration
; never null
setAttribute
public void setAttribute(
String name,
String value)
throws
SettingStoreException
- Stores an attribute to this
ISettingStore
, using the name
specified. If an attribute with the same name is already stored in that
ISettingStore
the previous value is replaced.
Any attribute stored to this ISettingStore using this method is considered
persisted from that point on.
If the value argument is null
, this has the same effect
as calling
removeAttribute(String)
.
SettingStoreListener
s attached to this instance will be notified
after an attribute has been stored.
-
-
Parameters:
-
name
- the name of the attribute; cannot be null
-
value
- the String to store; may be null
-
Throws:
-
SettingStoreException
- if the load operation failed to complete
normally
-
NullPointerException
- if name is null
removeAttribute
public void removeAttribute(
String name)
throws
SettingStoreException
- Removes the attribute stored under the specified name from this
ISettingStore
. 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;
cannot be null
-
Throws:
-
SettingStoreException
- if the remove operation failed to complete
normally
-
NullPointerException
- if name is null
loadById
public void loadById(
String id)
throws
SettingStoreException
- Replace the contents of this setting store with all attributes persisted
under the given
id
.
The attributes of this setting store before the load operation 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 value.
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.
It is important to note that this operation does not create a new setting
store, so that listeners still remain associated with the same store
instance. Instead the contents of this setting store are replaced
with the contents associated with the given id
.
-
-
Parameters:
-
id
- a non-null; non-empty; non-whitespace-only String
-
Throws:
-
SettingStoreException
- if the load operation failed to complete
normally
-
NullPointerException
- if id
is null
-
IllegalArgumentException
- if id
is empty or composed
entirely of whitespace
getId
public
String getId()
- Returns the unique identifier of this setting store
-
-
Returns:
- a non-empty String value; never null
addSettingStoreListener
public void addSettingStoreListener(
SettingStoreListener listener)
- Attaches an
SettingStoreListener
to this
ISettingStore
.
Listeners attached to this instance will notified of changes in the store.
-
-
Parameters:
-
listener
- the
SettingStoreListener
to add; non-null
removeSettingStoreListener
public void removeSettingStoreListener(
SettingStoreListener listener)
- Removes an
SettingStoreListener
from this
ISettingStore
.
-
-
Parameters:
-
listener
- the
SettingStoreListener
to remove; non-null
Copyright (c) Innoopract Informationssysteme GmbH and others 2002, 2008. All rights reserved.