Class DefaultSessionService
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.session.impl.DefaultSessionService
-
- All Implemented Interfaces:
SessionService
,java.io.Serializable
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
MockSessionService
public class DefaultSessionService extends AbstractService implements SessionService
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
Nested classes/interfaces inherited from interface de.hybris.platform.servicelayer.session.SessionService
SessionService.SessionAttributeLoader<T>
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultSessionService()
-
Method Summary
All Methods Instance Methods Concrete 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
.Session
createSession()
Must be overwritten! Use <lookup-method> in spring.java.lang.Object
executeInLocalView(SessionExecutionBody body)
Executes the givenSessionExecutionBody
in a localSessionContext
java.lang.Object
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()
shortcut to getCurrentSession().getAllAttributes().<T> T
getAttribute(java.lang.String name)
shortcut to getCurrentSession().getAttribute(String).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 sessionID)
Deprecated.since 5.5.1 session management was changed and this method always returns current session or 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)
shortcut to getCurrentSession().setAttribute(String,Object).void
setModelService(ModelService modelService)
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
-
-
-
Method Detail
-
getCurrentSession
public Session getCurrentSession()
- Specified by:
getCurrentSession
in interfaceSessionService
- Returns:
- the current
Session
-
getSession
@Deprecated public Session getSession(java.lang.String sessionID)
Deprecated.since 5.5.1 session management was changed and this method always returns current session or nullDescription copied from interface:SessionService
GetSession
by given id- Specified by:
getSession
in interfaceSessionService
-
createNewSession
public Session createNewSession()
Description copied from interface:SessionService
Creates a newSession
.- Specified by:
createNewSession
in interfaceSessionService
-
executeInLocalView
public java.lang.Object executeInLocalView(SessionExecutionBody body)
Description copied from interface:SessionService
Executes the givenSessionExecutionBody
in a localSessionContext
- Specified by:
executeInLocalView
in interfaceSessionService
-
executeInLocalViewWithParams
public <T> T executeInLocalViewWithParams(java.util.Map<java.lang.String,java.lang.Object> localViewParameters, SessionExecutionBody body)
Description copied from interface:SessionService
Executes the givenSessionExecutionBody
in a localSessionContext
that is populated with parameters provided in the map.- Specified by:
executeInLocalViewWithParams
in interfaceSessionService
- Parameters:
localViewParameters
- parameters that will be set in local viewbody
- callback to be invoked- Returns:
- callback result
-
executeInLocalView
public java.lang.Object executeInLocalView(SessionExecutionBody body, UserModel model)
Description copied from interface:SessionService
Executes the givenSessionExecutionBody
in a localSessionContext
and sets session user to given UserModel.- Specified by:
executeInLocalView
in interfaceSessionService
-
closeSession
public void closeSession(Session session)
Description copied from interface:SessionService
Closed the givenSession
- Specified by:
closeSession
in interfaceSessionService
- Parameters:
session
- the session which will be closed
-
closeCurrentSession
public void closeCurrentSession()
Description copied from interface:SessionService
Close the currentSession
- Specified by:
closeCurrentSession
in interfaceSessionService
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
shortcut to getCurrentSession().setAttribute(String,Object). this method is just a delegate to the Session object and it should not be overwritten.- Specified by:
setAttribute
in interfaceSessionService
- Parameters:
name
- name of the attributevalue
- the value to be set
-
removeAttribute
public void removeAttribute(java.lang.String name)
Description copied from interface:SessionService
Removes the given attribute from the current session. Do nothing if the attribute doesn't exists in the session.- Specified by:
removeAttribute
in interfaceSessionService
- Parameters:
name
- the attribute name
-
getAttribute
public <T> T getAttribute(java.lang.String name)
shortcut to getCurrentSession().getAttribute(String). this method is just a delegate to the Session object and it should not be overwritten- Specified by:
getAttribute
in interfaceSessionService
- Parameters:
name
- the attribute name- Returns:
null
if such attribute don't exist in the current session.
-
getOrLoadAttribute
public <T> T getOrLoadAttribute(java.lang.String name, SessionService.SessionAttributeLoader<T> loader)
Description copied from interface:SessionService
Returns for the given name the content which is stored in the currentSession
or loads a new value atomically by calling the loader instance.- Specified by:
getOrLoadAttribute
in interfaceSessionService
-
getAllAttributes
public <T> java.util.Map<java.lang.String,T> getAllAttributes()
shortcut to getCurrentSession().getAllAttributes(). this method is just a delegate to the Session object and it should not be overwritten- Specified by:
getAllAttributes
in interfaceSessionService
- Returns:
- all attributes from the current
Session
as Map.
-
hasCurrentSession
public boolean hasCurrentSession()
Description copied from interface:SessionService
Check if current session exists and neither closed nor inactive. KAM-158: Replacement forJaloSession.hasCurrentSession()
- Specified by:
hasCurrentSession
in interfaceSessionService
-
setModelService
public void setModelService(ModelService modelService)
-
createSession
public Session createSession()
Must be overwritten! Use <lookup-method> in spring.
-
getBoundSession
public Session getBoundSession(java.lang.Object rawSession)
Description copied from interface:SessionService
Returns service layer session bound to given JaloSession or creates new session (if no session is bound to given JaloSession) and returns it.- Specified by:
getBoundSession
in interfaceSessionService
-
getRawSession
public java.lang.Object getRawSession(Session session)
Description copied from interface:SessionService
Returns JaloSession bound to given service layer session.- Specified by:
getRawSession
in interfaceSessionService
-
-