Class SessionListener

  • All Implemented Interfaces:
    EventListener, javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener

    public class SessionListener
    extends Object
    implements javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener
    Keeps track of active sessions in this context so they can be marked as no active in database when they are destroyed. Also used to keep last activity info for CU management.
    • Constructor Detail

      • SessionListener

        public SessionListener()
    • Method Detail

      • sessionDestroyed

        public void sessionDestroyed​(javax.servlet.http.HttpSessionEvent event)
        This method is called whenever the session is destroyed because of user action or time out. It deactivates the session in db
        Specified by:
        sessionDestroyed in interface javax.servlet.http.HttpSessionListener
      • contextDestroyed

        public void contextDestroyed​(javax.servlet.ServletContextEvent event)
        This method is invoked when the server is shot down, it deactivates all sessions in this context.
        Specified by:
        contextDestroyed in interface javax.servlet.ServletContextListener
      • addSession

        public static void addSession​(String sessionId)
        Add a session to session tracking. This will be used when shut dowing the server
        sessionId - db id for the session to keep track
      • contextInitialized

        public void contextInitialized​(javax.servlet.ServletContextEvent event)
        Sets the current context and deactivates orphan sessions. Orphan sessions occur after a wrong context shutdown.
        Specified by:
        contextInitialized in interface javax.servlet.ServletContextListener
      • sessionCreated

        public void sessionCreated​(javax.servlet.http.HttpSessionEvent event)
        Specified by:
        sessionCreated in interface javax.servlet.http.HttpSessionListener
      • getActiveSession

        public static javax.servlet.http.HttpSession getActiveSession​(String sessionId)
        Returns the HttpSession identified by sessionId it is present in this context. If not present null is returned.
      • isSessionActiveInContext

        public static boolean isSessionActiveInContext​(String sessionId)
        Check whether a session is in the current context and it is active
        sessionId - session to check
        true in case it is in the context and active