Interface SessionService
- All Known Implementing Classes:
DefaultSessionService,MockSessionService
public interface SessionService
Provides access to the current
Session lifecycle and attributes.- Since:
- 4.0
- Spring Bean ID:
- sessionService
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInterface for loading attribute values while setting a new attribute in the current session. -
Method Summary
Modifier and TypeMethodDescriptionvoidClose the currentSessionvoidcloseSession(Session session) Closed the givenSessionCreates a newSession.<T> TExecutes the givenSessionExecutionBodyin a localSessionContext<T> TexecuteInLocalView(SessionExecutionBody body, UserModel model) Executes the givenSessionExecutionBodyin a localSessionContextand sets session user to given UserModel.<T> TexecuteInLocalViewWithParams(Map<String, Object> localViewParameters, SessionExecutionBody body) Executes the givenSessionExecutionBodyin a localSessionContextthat is populated with parameters provided in the map.<T> TgetAttribute(String name) Returns for the given attribute name the content which is stored in the currentSessiongetBoundSession(Object rawSession) Returns service layer session bound to given JaloSession or creates new session (if no session is bound to given JaloSession) and returns it.<T> TgetOrLoadAttribute(String name, SessionService.SessionAttributeLoader<T> loader) Returns for the given name the content which is stored in the currentSessionor loads a new value atomically by calling the loader instance.getRawSession(Session session) Returns JaloSession bound to given service layer session.getSession(String id) Deprecated, for removal: This API element is subject to removal in a future version.since 5.5.1 session management was changed and this method always returns nullbooleanCheck if current session exists and neither closed nor inactive.voidremoveAttribute(String name) Removes the given attribute from the current session.voidsetAttribute(String name, Object value) Set the given value object to the currentSessionas attribute with the given name.
-
Method Details
-
getCurrentSession
Session getCurrentSession()- Returns:
- the current
Session
-
getSession
Deprecated, for removal: This API element is subject to removal in a future version.since 5.5.1 session management was changed and this method always returns nullGetSessionby given id -
createNewSession
Session createNewSession()Creates a newSession. -
closeSession
Closed the givenSession- Parameters:
session- the session which will be closed
-
closeCurrentSession
void closeCurrentSession()Close the currentSession -
hasCurrentSession
boolean hasCurrentSession()Check if current session exists and neither closed nor inactive. KAM-158: Replacement forJaloSession.hasCurrentSession() -
setAttribute
Set the given value object to the currentSessionas attribute with the given name. If the value object is a (persisted) model than the model is written to the session attribute.- Parameters:
name- name of the attributevalue- the value to be set
-
getAttribute
Returns for the given attribute name the content which is stored in the currentSession- Parameters:
name- the attribute name- Returns:
nullif such attribute don't exist in the current session.
-
getOrLoadAttribute
Returns for the given name the content which is stored in the currentSessionor loads a new value atomically by calling the loader instance. -
getAllAttributes
- Returns:
- all attributes from the current
Sessionas Map.
-
executeInLocalView
Executes the givenSessionExecutionBodyin a localSessionContext -
executeInLocalViewWithParams
<T> T executeInLocalViewWithParams(Map<String, Object> localViewParameters, SessionExecutionBody body) Executes the givenSessionExecutionBodyin a localSessionContextthat is populated with parameters provided in the map.- Parameters:
localViewParameters- parameters that will be set in local viewbody- callback to be invoked- Returns:
- callback result
-
executeInLocalView
Executes the givenSessionExecutionBodyin a localSessionContextand sets session user to given UserModel. -
removeAttribute
Removes the given attribute from the current session. Do nothing if the attribute doesn't exists in the session.- Parameters:
name- the attribute name
-
getBoundSession
Returns service layer session bound to given JaloSession or creates new session (if no session is bound to given JaloSession) and returns it. -
getRawSession
Returns JaloSession bound to given service layer session.
-