Class SessionListener
java.lang.Object
com.vaadin.kubernetes.starter.sessiontracker.SessionListener
- All Implemented Interfaces:
jakarta.servlet.http.HttpSessionAttributeListener,jakarta.servlet.http.HttpSessionIdListener,jakarta.servlet.http.HttpSessionListener,EventListener
public class SessionListener
extends Object
implements jakarta.servlet.http.HttpSessionListener, jakarta.servlet.http.HttpSessionIdListener, jakarta.servlet.http.HttpSessionAttributeListener
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 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.voidattributeAdded(jakarta.servlet.http.HttpSessionBindingEvent event) voidattributeReplaced(jakarta.servlet.http.HttpSessionBindingEvent event) voidsessionCreated(jakarta.servlet.http.HttpSessionEvent se) voidsessionDestroyed(jakarta.servlet.http.HttpSessionEvent se) voidsessionIdChanged(jakarta.servlet.http.HttpSessionEvent event, String oldSessionId) voidstop()Stops this session listener to skip any furtherHttpSessionEventhandling.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.http.HttpSessionAttributeListener
attributeRemoved
-
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
-
sessionIdChanged
- Specified by:
sessionIdChangedin interfacejakarta.servlet.http.HttpSessionIdListener
-
attributeAdded
public void attributeAdded(jakarta.servlet.http.HttpSessionBindingEvent event) - Specified by:
attributeAddedin interfacejakarta.servlet.http.HttpSessionAttributeListener
-
attributeReplaced
public void attributeReplaced(jakarta.servlet.http.HttpSessionBindingEvent event) - Specified by:
attributeReplacedin interfacejakarta.servlet.http.HttpSessionAttributeListener
-
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.
-
stop
public void stop()Stops this session listener to skip any furtherHttpSessionEventhandling.
-