Class SessionListener
java.lang.Object
com.vaadin.kubernetes.starter.sessiontracker.SessionListener
- All Implemented Interfaces:
jakarta.servlet.http.HttpSessionListener,EventListener
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.-
Constructor Summary
ConstructorsConstructorDescriptionSessionListener(BackendConnector sessionBackendConnector, SessionSerializer sessionSerializer) Creates a newSessionListenerinstance. -
Method Summary
Modifier and TypeMethodDescriptionGets a predicate that tests if the given identifier matches an active HTTP session.voidsessionCreated(jakarta.servlet.http.HttpSessionEvent se) voidsessionDestroyed(jakarta.servlet.http.HttpSessionEvent se)
-
Constructor Details
-
SessionListener
public SessionListener(BackendConnector sessionBackendConnector, SessionSerializer sessionSerializer) Creates a newSessionListenerinstance.- 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:
sessionCreatedin interfacejakarta.servlet.http.HttpSessionListener
-
sessionDestroyed
public void sessionDestroyed(jakarta.servlet.http.HttpSessionEvent se) - Specified by:
sessionDestroyedin interfacejakarta.servlet.http.HttpSessionListener
-
activeSessionChecker
Gets a predicate that tests if the given identifier matches an active HTTP session.- Returns:
- a predicate to check if an HTTP session is active or not.
-