Class VaadinSessionFinder

java.lang.Object
org.dellroad.stuff.vaadin24.util.VaadinSessionFinder

public final class VaadinSessionFinder extends Object
Utility class for finding the VaadinSession associated with the current HTTP request when VaadinSession.getCurrent() isn't an option.

This class requires that Spring's RequestContextHolder is being used.

  • Method Details

    • find

      public static Optional<VaadinSession> find()
      Find the VaadinSession associated with the current HTTP request.

      The session is found by directly inspecting the current HTTP session, so this will work even if the current thread is not executing within the Vaadin servlet.

      This method relies on Spring's RequestContextHolder to locate the current HTTP request.

      Returns:
      the VaadinSession associated with the current HTTP request, if any
    • access

      public static boolean access(Runnable action)
      Invoke the given action in the context of the VaadinSession associated with the current HTTP request.
      Parameters:
      action - the action to perform
      Returns:
      true if successfully dispatched, false if session was not found
      Throws:
      IllegalArgumentException - if action is null