Class SessionWrapper

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class SessionWrapper
    extends Object
    implements Closeable
    The SessionWrapper can be used to ensure that there always is an existing session. This prevents the need to check if there is an active session and create one if there isn't yourself.
    Since:
    10.36.0
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionWrapper​(SessionManager sessionManager)
      Creates a new SessionWrapper, which in turn creates a new session if no session exists.
      SessionWrapper​(SessionManager sessionManager, int webId)
      Creates a new SessionWrapper, which in turn creates a new session using the provided web id if no session exists or if the id of the website in the active session context does not match the provided id.
      SessionWrapper​(SessionManager sessionManager, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Creates a new SessionWrapper, which in turn creates a new session if no session exists using or if the active sessions HttpServletRequest and HttpServletResponse do not match the request and response provided.
    • Constructor Detail

      • SessionWrapper

        public SessionWrapper​(SessionManager sessionManager)
        Creates a new SessionWrapper, which in turn creates a new session if no session exists. When the close method is called on the SessionWrapper the session is only closed if it was created by the SessionWrapper itself
        Parameters:
        sessionManager - the session manager is used to get the active session from and to create a new one if no session exists
      • SessionWrapper

        public SessionWrapper​(SessionManager sessionManager,
                              int webId)
        Creates a new SessionWrapper, which in turn creates a new session using the provided web id if no session exists or if the id of the website in the active session context does not match the provided id. When the close method is called on the SessionWrapper the session is only closed if it was created by the SessionWrapper itself.
        Parameters:
        sessionManager - the session manager is used to get the active session from and to create a new one if no session exists
        webId - the web id to use when creating a new session when there is no active session
      • SessionWrapper

        public SessionWrapper​(SessionManager sessionManager,
                              javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse resp)
        Creates a new SessionWrapper, which in turn creates a new session if no session exists using or if the active sessions HttpServletRequest and HttpServletResponse do not match the request and response provided. When a new session is created the provided HttpServletRequest and HttpServletResponse are used. When the close method is called on the SessionWrapper the session is only closed if it was created by the SessionWrapper itself
        Parameters:
        sessionManager - the session manager is used to get the active session from and to create a new one if no session exists
        req - the HttpServletRequest to create the session with, if there is no active session
        resp - the HttpServletResponse to create the session with, if there is no active session