Interface SessionService
-
- All Known Implementing Classes:
DefaultSessionService,MockSessionService,SAPMockSessionService
public interface SessionServiceProvides access to the currentSessionlifecycle and attributes.- Since:
- 4.0
- Spring Bean ID:
- sessionService
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceSessionService.SessionAttributeLoader<T>Interface for loading attribute values while setting a new attribute in the current session.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidcloseCurrentSession()Close the currentSessionvoidcloseSession(Session session)Closed the givenSessionSessioncreateNewSession()Creates a newSession.<T> TexecuteInLocalView(SessionExecutionBody body)Executes the givenSessionExecutionBodyin a localSessionContext<T> TexecuteInLocalView(SessionExecutionBody body, UserModel model)Executes the givenSessionExecutionBodyin a localSessionContextand sets session user to given UserModel.<T> TexecuteInLocalViewWithParams(java.util.Map<java.lang.String,java.lang.Object> localViewParameters, SessionExecutionBody body)Executes the givenSessionExecutionBodyin a localSessionContextthat is populated with parameters provided in the map.<T> java.util.Map<java.lang.String,T>getAllAttributes()<T> TgetAttribute(java.lang.String name)Returns for the given attribute name the content which is stored in the currentSessionSessiongetBoundSession(java.lang.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.SessiongetCurrentSession()<T> TgetOrLoadAttribute(java.lang.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.java.lang.ObjectgetRawSession(Session session)Returns JaloSession bound to given service layer session.SessiongetSession(java.lang.String id)Deprecated.since 5.5.1 session management was changed and this method always returns nullbooleanhasCurrentSession()Check if current session exists and neither closed nor inactive.voidremoveAttribute(java.lang.String name)Removes the given attribute from the current session.voidsetAttribute(java.lang.String name, java.lang.Object value)Set the given value object to the currentSessionas attribute with the given name.
-
-
-
Method Detail
-
getSession
@Deprecated Session getSession(java.lang.String id)
Deprecated.since 5.5.1 session management was changed and this method always returns nullGetSessionby given id
-
closeSession
void closeSession(Session session)
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
void setAttribute(java.lang.String name, java.lang.Object value)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
<T> T getAttribute(java.lang.String name)
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
<T> T getOrLoadAttribute(java.lang.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.
-
getAllAttributes
<T> java.util.Map<java.lang.String,T> getAllAttributes()
- Returns:
- all attributes from the current
Sessionas Map.
-
executeInLocalView
<T> T executeInLocalView(SessionExecutionBody body)
Executes the givenSessionExecutionBodyin a localSessionContext
-
executeInLocalViewWithParams
<T> T executeInLocalViewWithParams(java.util.Map<java.lang.String,java.lang.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
<T> T executeInLocalView(SessionExecutionBody body, UserModel model)
Executes the givenSessionExecutionBodyin a localSessionContextand sets session user to given UserModel.
-
removeAttribute
void removeAttribute(java.lang.String name)
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
Session getBoundSession(java.lang.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.
-
getRawSession
java.lang.Object getRawSession(Session session)
Returns JaloSession bound to given service layer session.
-
-