Class WebSessionFunctions

java.lang.Object
de.hybris.platform.util.WebSessionFunctions

public class WebSessionFunctions extends Object
Helper class for session handling.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Unassigns the current thread from its current http servlet request.
    static final void
    clearSession(javax.servlet.http.HttpSession session)
     
    static javax.servlet.http.HttpServletRequest
    Returns the http servlet request associated with the current thread, or null if no request had been stored.
    static javax.servlet.http.HttpSession
    Returns the http session associated with the current thread.
    static final JaloSession
    getSession(String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean skipSystemInitTest)
    returns a JaloSession object
    static final JaloSession
    getSession(String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Class sessionClass, boolean skipSystemInitTest)
    returns a JaloSession object
    static final JaloSession
    getSession(Map connProp, String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    returns a JaloSession object
    static final JaloSession
    getSession(Map _connProp, String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Class sessionClass)
    returns a JaloSession object
    static final JaloSession
    getSession(javax.servlet.http.HttpServletRequest request)
    returns a JaloSession object.
    static final JaloSession
    getSession(javax.servlet.http.HttpServletRequest request, boolean skipSystemInitTest)
    returns a JaloSession object.
    static final void
    invalidateSession(javax.servlet.http.HttpSession session)
    Closes the HTTP and JaloSession (if one is present under key 'jalosession').
    static boolean
    isStaleRequest(javax.servlet.http.HttpServletRequest request)
    Allows you to check if request is part of the stale session.
    static void
    markRequestAsStale(javax.servlet.http.HttpServletRequest request)
    Allows you to mark request as part of the stale session.
    static void
    setCurrentHttpServletRequest(javax.servlet.http.HttpServletRequest request)
    Assigns the given http servlet request to this thread.
    static final JaloSession
    tryGetJaloSession(javax.servlet.http.HttpSession session)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WebSessionFunctions

      public WebSessionFunctions()
  • Method Details

    • isStaleRequest

      public static boolean isStaleRequest(javax.servlet.http.HttpServletRequest request)
      Allows you to check if request is part of the stale session.
      Parameters:
      request - request to check.
      Returns:
      true if request is part of the stale session, false otherwise.
    • markRequestAsStale

      public static void markRequestAsStale(javax.servlet.http.HttpServletRequest request)
      Allows you to mark request as part of the stale session.
      Parameters:
      request - request to be marked.
    • getCurrentHttpServletRequest

      public static javax.servlet.http.HttpServletRequest getCurrentHttpServletRequest()
      Returns the http servlet request associated with the current thread, or null if no request had been stored.
      See Also:
    • getCurrentHttpSession

      public static javax.servlet.http.HttpSession getCurrentHttpSession()
      Returns the http session associated with the current thread. This is based on the current http servlet request being assigned to this thread. Therefore the method returns null if no request had been assigned.
      See Also:
    • clearCurrentHttpServletRequest

      public static void clearCurrentHttpServletRequest()
      Unassigns the current thread from its current http servlet request.
      See Also:
    • setCurrentHttpServletRequest

      public static void setCurrentHttpServletRequest(javax.servlet.http.HttpServletRequest request)
      Assigns the given http servlet request to this thread.
      See Also:
    • invalidateSession

      public static final void invalidateSession(javax.servlet.http.HttpSession session)
      Closes the HTTP and JaloSession (if one is present under key 'jalosession').
    • clearSession

      public static final void clearSession(javax.servlet.http.HttpSession session)
    • tryGetJaloSession

      public static final JaloSession tryGetJaloSession(javax.servlet.http.HttpSession session)
    • getSession

      public static final JaloSession getSession(javax.servlet.http.HttpServletRequest request) throws JaloConnectException, JaloSystemNotInitializedException
      returns a JaloSession object.

      If you don't want to use cookies and are connecting to the local server, this is the preferred method to get or create a JaloSession object.

      Parameters:
      request - the HttpServletRequest object
      Returns:
      the JaloSession
      Throws:
      JaloConnectException - in case of a connection error
      JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
    • getSession

      public static final JaloSession getSession(Map connProp, String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws JaloSystemNotInitializedException
      returns a JaloSession object

      1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
      2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
      3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
      Parameters:
      connProp - deprecated, use always NULL

      cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
      session - the HttpSession object
      request - the HttpServletRequest object
      response - the HttpServletRespone object
      Throws:
      JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
    • getSession

      public static final JaloSession getSession(Map _connProp, String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Class sessionClass) throws JaloSystemNotInitializedException
      returns a JaloSession object

      1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
      2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
      3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
      Parameters:
      _connProp - Deprecated, use always NULL

      cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
      session - the HttpSession object
      request - the HttpServletRequest object
      response - the HttpServletRespone object
      sessionClass - the jalo class of the new session, if null JaloSession will be taken
      Throws:
      JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
    • getSession

      public static final JaloSession getSession(javax.servlet.http.HttpServletRequest request, boolean skipSystemInitTest) throws JaloConnectException, JaloSystemNotInitializedException
      returns a JaloSession object.

      If you don't want to use cookies and are connecting to the local server, this is the preferred method to get or create a JaloSession object.

      Parameters:
      request - the HttpServletRequest object
      skipSystemInitTest - is true, this metod will not execute a db statement in order to determine if the system is initialize
      Returns:
      the JaloSession
      Throws:
      JaloConnectException - in case of a connection error
      JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
    • getSession

      public static final JaloSession getSession(String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean skipSystemInitTest) throws JaloSystemNotInitializedException
      returns a JaloSession object

      1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
      2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
      3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
      Parameters:
      cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
      session - the HttpSession object
      request - the HttpServletRequest object
      response - the HttpServletRespone object
      skipSystemInitTest - is true, this metod will not execute a db statement in order to determine if the system is initialize
      Throws:
      JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
    • getSession

      public static final JaloSession getSession(String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Class sessionClass, boolean skipSystemInitTest) throws JaloSystemNotInitializedException
      returns a JaloSession object

      1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
      2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
      3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
      Parameters:
      cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
      session - the HttpSession object
      request - the HttpServletRequest object
      response - the HttpServletRespone object
      sessionClass - the jalo class of the new session, if null JaloSession will be taken
      skipSystemInitTest - is true, this metod will not execute a db statement in order to determine if the system is initialize
      Throws:
      JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized