Class DefaultHttpSessionManager

java.lang.Object
cloud.piranha.core.impl.DefaultHttpSessionManager
All Implemented Interfaces:
HttpSessionManager, jakarta.servlet.ServletRequestListener, jakarta.servlet.SessionCookieConfig, EventListener

public class DefaultHttpSessionManager extends Object implements HttpSessionManager, jakarta.servlet.SessionCookieConfig, jakarta.servlet.ServletRequestListener
The default HttpSessionManager.
Author:
Manfred Riem ([email protected])
  • Field Details

    • attributeListeners

      protected final ArrayList<jakarta.servlet.http.HttpSessionAttributeListener> attributeListeners
      Stores the session listeners.
    • comment

      protected String comment
      Stores the comment.
    • defaultSessionTrackingModes

      protected final Set<jakarta.servlet.SessionTrackingMode> defaultSessionTrackingModes
      Stores the default session tracking modes.
    • domain

      protected String domain
      Stores the domain.
    • httpOnly

      protected boolean httpOnly
      Stores the HTTP only flag.
    • idListeners

      protected final ArrayList<jakarta.servlet.http.HttpSessionIdListener> idListeners
      Stores the session id listeners.
    • maxAge

      protected int maxAge
      Stores the max age.
    • name

      protected String name
      Stores the name.
    • path

      protected String path
      Stores the path.
    • secure

      protected boolean secure
      Stores the secure flag.
    • sessionCounters

      protected final Map<String,AtomicInteger> sessionCounters
      Stores the session counters.
    • sessionCookieAttributes

      protected HashMap<String,String> sessionCookieAttributes
      Stores the cookie attributes.
    • sessionListeners

      protected final ArrayList<jakarta.servlet.http.HttpSessionListener> sessionListeners
      Stores the session listeners.
    • sessionTimeout

      protected int sessionTimeout
      Stores the session timeout (in minutes).
    • sessionTrackingModes

      protected Set<jakarta.servlet.SessionTrackingMode> sessionTrackingModes
      Stores the session tracking modes.
    • sessions

      protected Map<String,jakarta.servlet.http.HttpSession> sessions
      Stores the sessions.
    • webApplication

      protected WebApplication webApplication
      Stores the web application.
  • Constructor Details

    • DefaultHttpSessionManager

      public DefaultHttpSessionManager()
      Constructor.
  • Method Details

    • addListener

      public <T extends EventListener> void addListener(T listener)
      Description copied from interface: HttpSessionManager
      Add a listener.
      Specified by:
      addListener in interface HttpSessionManager
      Type Parameters:
      T - the type.
      Parameters:
      listener - the listener.
    • attributeAdded

      public void attributeAdded(jakarta.servlet.http.HttpSession session, String name, Object value)
      Description copied from interface: HttpSessionManager
      Attribute added.
      Specified by:
      attributeAdded in interface HttpSessionManager
      Parameters:
      session - the HTTP session.
      name - the name.
      value - the value.
    • attributeRemoved

      public void attributeRemoved(jakarta.servlet.http.HttpSession session, String name, Object value)
      Description copied from interface: HttpSessionManager
      Attribute removed.
      Specified by:
      attributeRemoved in interface HttpSessionManager
      Parameters:
      session - the HTTP session.
      name - the name.
      value - the value.
    • attributeReplaced

      public void attributeReplaced(jakarta.servlet.http.HttpSession session, String name, Object oldValue, Object newValue)
      Description copied from interface: HttpSessionManager
      Attribute replaced.
      Specified by:
      attributeReplaced in interface HttpSessionManager
      Parameters:
      session - the HTTP session.
      name - the name.
      oldValue - the old value.
      newValue - the new value.
    • changeSessionId

      public String changeSessionId(jakarta.servlet.http.HttpServletRequest request)
      Description copied from interface: HttpSessionManager
      Change the session id and return it.
      Specified by:
      changeSessionId in interface HttpSessionManager
      Parameters:
      request - the request.
      Returns:
      the session id.
    • createSession

      public jakarta.servlet.http.HttpSession createSession(jakarta.servlet.http.HttpServletRequest request)
      Description copied from interface: HttpSessionManager
      Create a session.
      Specified by:
      createSession in interface HttpSessionManager
      Parameters:
      request - the request.
      Returns:
      the session.
    • destroySession

      public void destroySession(jakarta.servlet.http.HttpSession session)
      Description copied from interface: HttpSessionManager
      Destroys a session.
      Specified by:
      destroySession in interface HttpSessionManager
      Parameters:
      session - the HTTP session.
    • encodeRedirectURL

      public String encodeRedirectURL(jakarta.servlet.http.HttpServletResponse response, String url)
      Description copied from interface: HttpSessionManager
      Encode the redirect URL.
      Specified by:
      encodeRedirectURL in interface HttpSessionManager
      Parameters:
      response - the HTTP servlet response.
      url - the URL.
      Returns:
      the encode URL.
    • encodeURL

      public String encodeURL(jakarta.servlet.http.HttpServletResponse response, String url)
      Description copied from interface: HttpSessionManager
      Encode the URL.
      Specified by:
      encodeURL in interface HttpSessionManager
      Parameters:
      response - the HTTP servlet response.
      url - the URL.
      Returns:
      the encoded URL.
    • getComment

      public String getComment()
      Specified by:
      getComment in interface jakarta.servlet.SessionCookieConfig
    • getDefaultSessionTrackingModes

      public Set<jakarta.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
      Description copied from interface: HttpSessionManager
      Returns the default session tracking modes.
      Specified by:
      getDefaultSessionTrackingModes in interface HttpSessionManager
      Returns:
      the default session tracking modes
    • getDomain

      public String getDomain()
      Specified by:
      getDomain in interface jakarta.servlet.SessionCookieConfig
    • getEffectiveSessionTrackingModes

      public Set<jakarta.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
      Description copied from interface: HttpSessionManager
      Returns the effective session tracking modes.
      Specified by:
      getEffectiveSessionTrackingModes in interface HttpSessionManager
      Returns:
      the effective session tracking modes
    • getMaxAge

      public int getMaxAge()
      Specified by:
      getMaxAge in interface jakarta.servlet.SessionCookieConfig
    • getName

      public String getName()
      Specified by:
      getName in interface jakarta.servlet.SessionCookieConfig
    • getPath

      public String getPath()
      Specified by:
      getPath in interface jakarta.servlet.SessionCookieConfig
    • getSession

      public jakarta.servlet.http.HttpSession getSession(jakarta.servlet.http.HttpServletRequest request, String currentSessionId)
      Description copied from interface: HttpSessionManager
      Returns the session.
      Specified by:
      getSession in interface HttpSessionManager
      Parameters:
      request - the request.
      currentSessionId - the current session id.
      Returns:
      the session
    • getSessionCookieConfig

      public jakarta.servlet.SessionCookieConfig getSessionCookieConfig()
      Description copied from interface: HttpSessionManager
      Returns the session cookie config.
      Specified by:
      getSessionCookieConfig in interface HttpSessionManager
      Returns:
      the session cookie config
    • getSessionTimeout

      public int getSessionTimeout()
      Description copied from interface: HttpSessionManager
      Get the session timeout (in minutes).
      Specified by:
      getSessionTimeout in interface HttpSessionManager
      Returns:
      the session timeout.
    • hasSession

      public boolean hasSession(String sessionId)
      Description copied from interface: HttpSessionManager
      Is the session manager handling this session?
      Specified by:
      hasSession in interface HttpSessionManager
      Parameters:
      sessionId - the session id.
      Returns:
      true if there is a session with the given session id.
    • isHttpOnly

      public boolean isHttpOnly()
      Specified by:
      isHttpOnly in interface jakarta.servlet.SessionCookieConfig
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface jakarta.servlet.SessionCookieConfig
    • reapSessions

      protected void reapSessions()
      Reap any inactive session.
    • setComment

      public void setComment(String comment)
      Specified by:
      setComment in interface jakarta.servlet.SessionCookieConfig
    • setDomain

      public void setDomain(String domain)
      Specified by:
      setDomain in interface jakarta.servlet.SessionCookieConfig
    • setHttpOnly

      public void setHttpOnly(boolean httpOnly)
      Specified by:
      setHttpOnly in interface jakarta.servlet.SessionCookieConfig
    • setMaxAge

      public void setMaxAge(int maxAge)
      Specified by:
      setMaxAge in interface jakarta.servlet.SessionCookieConfig
    • setName

      public void setName(String name)
      Specified by:
      setName in interface jakarta.servlet.SessionCookieConfig
    • setPath

      public void setPath(String path)
      Specified by:
      setPath in interface jakarta.servlet.SessionCookieConfig
    • setSecure

      public void setSecure(boolean secure)
      Specified by:
      setSecure in interface jakarta.servlet.SessionCookieConfig
    • setSessionTimeout

      public void setSessionTimeout(int sessionTimeout)
      Description copied from interface: HttpSessionManager
      Set the session timeout (in minutes).
      Specified by:
      setSessionTimeout in interface HttpSessionManager
      Parameters:
      sessionTimeout - the timeout.
    • setSessionTrackingModes

      public void setSessionTrackingModes(Set<jakarta.servlet.SessionTrackingMode> sessionTrackingModes)
      Description copied from interface: HttpSessionManager
      Set the session tracking modes.
      Specified by:
      setSessionTrackingModes in interface HttpSessionManager
      Parameters:
      sessionTrackingModes - the session tracking modes.
    • setWebApplication

      public void setWebApplication(WebApplication webApplication)
      Description copied from interface: HttpSessionManager
      Set the web application.
      Specified by:
      setWebApplication in interface HttpSessionManager
      Parameters:
      webApplication - the web application.
    • requestInitialized

      public void requestInitialized(jakarta.servlet.ServletRequestEvent event)
      Specified by:
      requestInitialized in interface jakarta.servlet.ServletRequestListener
    • requestDestroyed

      public void requestDestroyed(jakarta.servlet.ServletRequestEvent event)
      Specified by:
      requestDestroyed in interface jakarta.servlet.ServletRequestListener
    • setAttribute

      public void setAttribute(String name, String value)
      Specified by:
      setAttribute in interface jakarta.servlet.SessionCookieConfig
    • getAttribute

      public String getAttribute(String name)
      Specified by:
      getAttribute in interface jakarta.servlet.SessionCookieConfig
    • getAttributes

      public Map<String,String> getAttributes()
      Specified by:
      getAttributes in interface jakarta.servlet.SessionCookieConfig