java.lang.Object
com.vaadin.kubernetes.starter.sessiontracker.SessionUtil

public class SessionUtil extends Object
Utility class for session operations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Runnable
    injectLockIfNeeded(com.vaadin.flow.server.VaadinSession session)
    VaadinSession lock is usually set by calling VaadinSession.refreshTransients(WrappedSession, VaadinService), but during deserialization none of the required objects are available.
    static Runnable
    injectServiceIfNeeded(com.vaadin.flow.server.VaadinSession session)
    VaadinSession service field is usually set by calling VaadinSession.refreshTransients(WrappedSession, VaadinService), but during deserialization WrappedSession is not available and the call will fail when refreshing the session lock.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SessionUtil

      public SessionUtil()
  • Method Details

    • injectLockIfNeeded

      public static Runnable injectLockIfNeeded(com.vaadin.flow.server.VaadinSession session)
      VaadinSession lock is usually set by calling VaadinSession.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 provided VaadinSession, 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

      public static Runnable injectServiceIfNeeded(com.vaadin.flow.server.VaadinSession session)
      VaadinSession service field is usually set by calling VaadinSession.refreshTransients(WrappedSession, VaadinService), but during deserialization WrappedSession is not available and the call will fail when refreshing the session lock. This method gets the Vaadin service instance from VaadinService.getCurrent(), and if available injects it into the provided VaadinSession. 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