Class SessionTrackerCookie
java.lang.Object
com.vaadin.kubernetes.starter.sessiontracker.SessionTrackerCookie
Utility class to handle the storage of the distributed storage session key.
-
Method Summary
Modifier and TypeMethodDescriptiongetFromSession(jakarta.servlet.http.HttpSession session) Gets the current distributed storage session key from HTTP session.getValue(jakarta.servlet.http.HttpServletRequest request) Deprecated, for removal: This API element is subject to removal in a future version.Gets the value of the current distributed storage session key from the Cookie.static voidsetIfNeeded(jakarta.servlet.http.HttpSession session, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String cookieName, Consumer<jakarta.servlet.http.Cookie> cookieConsumer) Sets the distributed storage session key on the HTTP session.static voidsetIfNeeded(jakarta.servlet.http.HttpSession session, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Consumer<jakarta.servlet.http.Cookie> cookieConsumer) Deprecated, for removal: This API element is subject to removal in a future version.usesetIfNeeded(HttpSession, HttpServletRequest, HttpServletResponse, String, Consumer)providing the cluster cookie name instead.
-
Method Details
-
setIfNeeded
@Deprecated(since="2.4", forRemoval=true) public static void setIfNeeded(jakarta.servlet.http.HttpSession session, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Consumer<jakarta.servlet.http.Cookie> cookieConsumer) Deprecated, for removal: This API element is subject to removal in a future version.usesetIfNeeded(HttpSession, HttpServletRequest, HttpServletResponse, String, Consumer)providing the cluster cookie name instead.Sets the distributed storage session key on the HTTP session. If the Cookie does not exist, a new key is generated and the Cookie is created and added to the HTTP response.- Parameters:
session- the HTTP session.request- the HTTP request.response- the HTTP response.cookieConsumer- function to apply custom setting to the cluster key cookie.
-
setIfNeeded
public static void setIfNeeded(jakarta.servlet.http.HttpSession session, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String cookieName, Consumer<jakarta.servlet.http.Cookie> cookieConsumer) Sets the distributed storage session key on the HTTP session. If the Cookie does not exist, a new key is generated and the Cookie is created and added to the HTTP response.- Parameters:
session- the HTTP session.request- the HTTP request.response- the HTTP response.cookieName- the name for the cluster cookie.cookieConsumer- function to apply custom setting to the cluster key cookie.
-
getFromSession
Gets the current distributed storage session key from HTTP session.- Parameters:
session- the HTTP session.- Returns:
- the current distributed storage session key wrapped into an
Optional, or an empty Optional if the key does not exist.
-
getValue
@Deprecated(since="2.4", forRemoval=true) public static Optional<String> getValue(jakarta.servlet.http.HttpServletRequest request) Deprecated, for removal: This API element is subject to removal in a future version.usegetValue(HttpServletRequest, String)providing the cluster cookie name instead.Gets the value of the current distributed storage session key from the Cookie.- Parameters:
request- the HTTP request.- Returns:
- the current distributed storage session key wrapped into an
Optional, or an empty Optional if the Cookie does not exist.
-
getValue
public static Optional<String> getValue(jakarta.servlet.http.HttpServletRequest request, String cookieName) Gets the value of the current distributed storage session key from the Cookie.- Parameters:
request- the HTTP request.cookieName- the name of the cluster key cookie.- Returns:
- the current distributed storage session key wrapped into an
Optional, or an empty Optional if the Cookie does not exist.
-
getValue(HttpServletRequest, String)providing the cluster cookie name instead.