Class SessionListener

java.lang.Object
com.vaadin.kubernetes.starter.sessiontracker.SessionListener
All Implemented Interfaces:
jakarta.servlet.http.HttpSessionListener, EventListener

public class SessionListener extends Object implements jakarta.servlet.http.HttpSessionListener
An HttpSessionListener implementation that handles population and destruction of session data stored on a distributed storage. In presence of a tracking Cookie set by SessionTrackerFilter, on session creation, the distributed storage is queried for persisted attributes that are then used to populate the newly created HttpSession. Data is fetched in binary format from the distributed storage by a BackendConnector and then deserialized and copied into HTTP session by SessionSerializer. When HTTP session is destroyed, also relative data on distribute storage is deleted by the backend connector.
See Also:
  • Constructor Details

    • SessionListener

      public SessionListener(BackendConnector sessionBackendConnector, SessionSerializer sessionSerializer)
      Creates a new SessionListener instance.
      Parameters:
      sessionBackendConnector - backend connector to fetch and delete session data from distributed storage.
      sessionSerializer - component to perform deserialization of data from distributed storage.
  • Method Details

    • sessionCreated

      public void sessionCreated(jakarta.servlet.http.HttpSessionEvent se)
      Specified by:
      sessionCreated in interface jakarta.servlet.http.HttpSessionListener
    • sessionDestroyed

      public void sessionDestroyed(jakarta.servlet.http.HttpSessionEvent se)
      Specified by:
      sessionDestroyed in interface jakarta.servlet.http.HttpSessionListener