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
  • Method Details

    • getCurrentSession

      Session getCurrentSession()
      Returns:
      the current Session
    • getSession

      @Deprecated(since="5.5.1", forRemoval=true) 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 null
      Get Session by given id
    • createNewSession

      Session createNewSession()
      Creates a new Session.
    • closeSession

      void closeSession(Session session)
      Closed the given Session
      Parameters:
      session - the session which will be closed
    • closeCurrentSession

      void closeCurrentSession()
      Close the current Session
    • hasCurrentSession

      boolean hasCurrentSession()
      Check if current session exists and neither closed nor inactive. KAM-158: Replacement for JaloSession.hasCurrentSession()
    • setAttribute

      void setAttribute(String name, Object value)
      Set the given value object to the current Session 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 attribute
      value - the value to be set
    • getAttribute

      <T> T getAttribute(String name)
      Returns for the given attribute name the content which is stored in the current Session
      Parameters:
      name - the attribute name
      Returns:
      null if such attribute don't exist in the current session.
    • getOrLoadAttribute

      <T> T getOrLoadAttribute(String name, SessionService.SessionAttributeLoader<T> loader)
      Returns for the given name the content which is stored in the current Session or loads a new value atomically by calling the loader instance.
    • getAllAttributes

      <T> Map<String,T> getAllAttributes()
      Returns:
      all attributes from the current Session as Map.
    • executeInLocalView

      <T> T executeInLocalView(SessionExecutionBody body)
      Executes the given SessionExecutionBody in a local SessionContext
    • executeInLocalViewWithParams

      <T> T executeInLocalViewWithParams(Map<String,Object> localViewParameters, SessionExecutionBody body)
      Executes the given SessionExecutionBody in a local SessionContext that is populated with parameters provided in the map.
      Parameters:
      localViewParameters - parameters that will be set in local view
      body - callback to be invoked
      Returns:
      callback result
    • executeInLocalView

      <T> T executeInLocalView(SessionExecutionBody body, UserModel model)
      Executes the given SessionExecutionBody in a local SessionContext and sets session user to given UserModel.
    • removeAttribute

      void removeAttribute(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(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

      Object getRawSession(Session session)
      Returns JaloSession bound to given service layer session.