Interface SessionService
-
- All Known Implementing Classes:
DefaultSessionService
,MockSessionService
,SAPMockSessionService
public interface SessionService
Provides access to the currentSession
lifecycle and attributes.- Since:
- 4.0
- Spring Bean ID:
- sessionService
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SessionService.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 void
closeCurrentSession()
Close the currentSession
void
closeSession(Session session)
Closed the givenSession
Session
createNewSession()
Creates a newSession
.<T> T
executeInLocalView(SessionExecutionBody body)
Executes the givenSessionExecutionBody
in a localSessionContext
<T> T
executeInLocalView(SessionExecutionBody body, UserModel model)
Executes the givenSessionExecutionBody
in a localSessionContext
and sets session user to given UserModel.<T> T
executeInLocalViewWithParams(java.util.Map<java.lang.String,java.lang.Object> localViewParameters, SessionExecutionBody body)
Executes the givenSessionExecutionBody
in a localSessionContext
that is populated with parameters provided in the map.<T> java.util.Map<java.lang.String,T>
getAllAttributes()
<T> T
getAttribute(java.lang.String name)
Returns for the given attribute name the content which is stored in the currentSession
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.Session
getCurrentSession()
<T> T
getOrLoadAttribute(java.lang.String name, SessionService.SessionAttributeLoader<T> loader)
Returns for the given name the content which is stored in the currentSession
or loads a new value atomically by calling the loader instance.java.lang.Object
getRawSession(Session session)
Returns JaloSession bound to given service layer session.Session
getSession(java.lang.String id)
Deprecated.since 5.5.1 session management was changed and this method always returns nullboolean
hasCurrentSession()
Check if current session exists and neither closed nor inactive.void
removeAttribute(java.lang.String name)
Removes the given attribute from the current session.void
setAttribute(java.lang.String name, java.lang.Object value)
Set the given value object to the currentSession
as 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 nullGetSession
by 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 currentSession
as 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:
null
if 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 currentSession
or 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
Session
as Map.
-
executeInLocalView
<T> T executeInLocalView(SessionExecutionBody body)
Executes the givenSessionExecutionBody
in a localSessionContext
-
executeInLocalViewWithParams
<T> T executeInLocalViewWithParams(java.util.Map<java.lang.String,java.lang.Object> localViewParameters, SessionExecutionBody body)
Executes the givenSessionExecutionBody
in a localSessionContext
that 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 givenSessionExecutionBody
in a localSessionContext
and 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.
-
-