Class SessionUtil
java.lang.Object
com.vaadin.kubernetes.starter.sessiontracker.SessionUtil
Utility class for session operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RunnableinjectLockIfNeeded(com.vaadin.flow.server.VaadinSession session) VaadinSession lock is usually set by callingVaadinSession.refreshTransients(WrappedSession, VaadinService), but during deserialization none of the required objects are available.static RunnableinjectServiceIfNeeded(com.vaadin.flow.server.VaadinSession session) VaadinSession service field is usually set by callingVaadinSession.refreshTransients(WrappedSession, VaadinService), but during deserializationWrappedSessionis not available and the call will fail when refreshing the session lock.
-
Constructor Details
-
SessionUtil
public SessionUtil()
-
-
Method Details
-
injectLockIfNeeded
VaadinSession lock is usually set by callingVaadinSession.refreshTransients(WrappedSession, VaadinService), but during deserialization none of the required objects are available. This method gets the lock instance if exists, or injects a temporary lock instance into the providedVaadinSession, acquires the lock, and returns a runnable that will unlock or remove the lock when executed.- Parameters:
session- the session to be locked if needed- Returns:
- a runnable that will unlock or remove the lock when executed, or a no-op in case of any error
-
injectServiceIfNeeded
VaadinSession service field is usually set by callingVaadinSession.refreshTransients(WrappedSession, VaadinService), but during deserializationWrappedSessionis not available and the call will fail when refreshing the session lock. This method gets the Vaadin service instance fromVaadinService.getCurrent(), and if available injects it into the providedVaadinSession. The method returns a runnable that will unset the temporary service instance.- Parameters:
session- the session to be injected with VaadinService- Returns:
- a runnable that will remove the Vaadin service instance from the VaadinSession when executed, or a no-op in case of any error
-