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 voidcloseCurrentSession()Close the currentSessionvoidcloseSession(Session session)Closed the givenSessionSessioncreateNewSession()Creates a newSession.SessioncreateSession()Must be overwritten! Use <lookup-method> in spring.java.lang.ObjectexecuteInLocalView(SessionExecutionBody body)Executes the givenSessionExecutionBodyin a localSessionContextjava.lang.ObjectexecuteInLocalView(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()shortcut to getCurrentSession().getAllAttributes().<T> TgetAttribute(java.lang.String name)shortcut to getCurrentSession().getAttribute(String).SessiongetBoundSession(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 sessionID)Deprecated.since 5.5.1 session management was changed and this method always returns current session or 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)shortcut to getCurrentSession().setAttribute(String,Object).voidsetModelService(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:
getCurrentSessionin 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:SessionServiceGetSessionby given id- Specified by:
getSessionin interfaceSessionService
-
createNewSession
public Session createNewSession()
Description copied from interface:SessionServiceCreates a newSession.- Specified by:
createNewSessionin interfaceSessionService
-
executeInLocalView
public java.lang.Object executeInLocalView(SessionExecutionBody body)
Description copied from interface:SessionServiceExecutes the givenSessionExecutionBodyin a localSessionContext- Specified by:
executeInLocalViewin interfaceSessionService
-
executeInLocalViewWithParams
public <T> T executeInLocalViewWithParams(java.util.Map<java.lang.String,java.lang.Object> localViewParameters, SessionExecutionBody body)Description copied from interface:SessionServiceExecutes the givenSessionExecutionBodyin a localSessionContextthat is populated with parameters provided in the map.- Specified by:
executeInLocalViewWithParamsin 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:SessionServiceExecutes the givenSessionExecutionBodyin a localSessionContextand sets session user to given UserModel.- Specified by:
executeInLocalViewin interfaceSessionService
-
closeSession
public void closeSession(Session session)
Description copied from interface:SessionServiceClosed the givenSession- Specified by:
closeSessionin interfaceSessionService- Parameters:
session- the session which will be closed
-
closeCurrentSession
public void closeCurrentSession()
Description copied from interface:SessionServiceClose the currentSession- Specified by:
closeCurrentSessionin 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:
setAttributein interfaceSessionService- Parameters:
name- name of the attributevalue- the value to be set
-
removeAttribute
public void removeAttribute(java.lang.String name)
Description copied from interface:SessionServiceRemoves the given attribute from the current session. Do nothing if the attribute doesn't exists in the session.- Specified by:
removeAttributein 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:
getAttributein interfaceSessionService- Parameters:
name- the attribute name- Returns:
nullif 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:SessionServiceReturns for the given name the content which is stored in the currentSessionor loads a new value atomically by calling the loader instance.- Specified by:
getOrLoadAttributein 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:
getAllAttributesin interfaceSessionService- Returns:
- all attributes from the current
Sessionas Map.
-
hasCurrentSession
public boolean hasCurrentSession()
Description copied from interface:SessionServiceCheck if current session exists and neither closed nor inactive. KAM-158: Replacement forJaloSession.hasCurrentSession()- Specified by:
hasCurrentSessionin 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:SessionServiceReturns service layer session bound to given JaloSession or creates new session (if no session is bound to given JaloSession) and returns it.- Specified by:
getBoundSessionin interfaceSessionService
-
getRawSession
public java.lang.Object getRawSession(Session session)
Description copied from interface:SessionServiceReturns JaloSession bound to given service layer session.- Specified by:
getRawSessionin interfaceSessionService
-
-