|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.application.session.ApplicationSession
public final class ApplicationSession
This object is a singleton that will: act as a storage for session and user variables, registers itself on ApplicationEvents and can be used to monitor changes on the contained variables.
Field Summary | |
---|---|
static String |
SESSION_ATTRIBUTES
Property that can be monitored. |
static String |
USER
Property that can be monitored. |
static String |
USER_ATTRIBUTES
Property that can be monitored. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(String property,
PropertyChangeListener listener)
Register a listener on the specified property. |
void |
clearSession()
Clear all session attributes. |
void |
clearUser()
Clear all user attributes. |
ApplicationSessionInitializer |
getApplicationSessionInitializer()
|
Object |
getAttribute(String key)
Get a value from the user OR session attributes map. |
Object |
getAttribute(String key,
Object defaultValue)
Get a value from the user OR session attributes map. |
static ApplicationSession |
getSession()
Get the instance: Singleton Pattern. |
Object |
getSessionAttribute(String key)
Get a value from the session attributes map. |
Object |
getSessionAttribute(String key,
Object defaultValue)
Get a value from the session attributes map. |
Object |
getUserAttribute(String key)
gets a named attribute of the user associated to this context |
Object |
getUserAttribute(String key,
Object defaultValue)
Get a value from the user attributes map. |
protected void |
handleLoginEvent(LoginEvent event)
When a correct login occurs, read all relevant userinformation into session. |
protected void |
handleLogoutEvent(LogoutEvent event)
When a logout occurs, remove all user related information from the session. |
void |
initializeSession()
Initialize the session attributes. |
void |
onApplicationEvent(ApplicationEvent event)
Handle events that influence the session/user context. |
void |
removePropertyChangeListener(String property,
PropertyChangeListener listener)
Unregister a listener from the specified property. |
void |
setApplicationSessionInitializer(ApplicationSessionInitializer applicationSessionInitializer)
Set an initializer object containing vars/commands and custom init code. |
void |
setSessionAttribute(String key,
Object newValue)
Add a key/value pair to the session attributes map. |
void |
setSessionAttributes(Map<String,Object> attributes)
Add the given key/value pairs to the session attributes. |
void |
setUserAttribute(String key,
Object newValue)
Add a key/value pair to the user attributes map. |
void |
setUserAttributes(Map<String,Object> attributes)
Add the given key/value pairs to the user attributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String USER
public static final String USER_ATTRIBUTES
public static final String SESSION_ATTRIBUTES
Method Detail |
---|
public static ApplicationSession getSession()
public void onApplicationEvent(ApplicationEvent event)
onApplicationEvent
in interface ApplicationListener
protected void handleLoginEvent(LoginEvent event)
event
- the loginEvent that triggered this handler.protected void handleLogoutEvent(LogoutEvent event)
event
- the logoutEvent that triggered this handler.public void setApplicationSessionInitializer(ApplicationSessionInitializer applicationSessionInitializer)
applicationSessionInitializer
- The application session initializerpublic ApplicationSessionInitializer getApplicationSessionInitializer()
public void addPropertyChangeListener(String property, PropertyChangeListener listener)
property
- Property to monitor.listener
- PropertyChangeListener to add.public void removePropertyChangeListener(String property, PropertyChangeListener listener)
property
- Property that currently is being monitored.listener
- PropertyChangeListener to remove.public void initializeSession()
public Object getUserAttribute(String key)
key
- name of the attribute
public Object getUserAttribute(String key, Object defaultValue)
key
- name of the attributedefaultValue
- a default value to return if no value is found.
public void setUserAttribute(String key, Object newValue)
key
- a unique string code.newValue
- the associated value.public void setUserAttributes(Map<String,Object> attributes)
attributes
- a map of key/value pairs.public void clearUser()
public Object getSessionAttribute(String key)
key
- name of the attribute
public Object getSessionAttribute(String key, Object defaultValue)
key
- a unique string codedefaultValue
- the default value if not found
public void setSessionAttribute(String key, Object newValue)
key
- a unique string code.newValue
- the associated value.public void setSessionAttributes(Map<String,Object> attributes)
attributes
- a map of key/value pairs.public void clearSession()
public Object getAttribute(String key)
key
- name of the attribute
public Object getAttribute(String key, Object defaultValue)
key
- name of the attributedefaultValue
- a default value to return if no value is found.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |