Class RootMappedCondition

java.lang.Object
com.vaadin.flow.spring.RootMappedCondition
All Implemented Interfaces:
org.springframework.context.annotation.Condition

public class RootMappedCondition extends Object implements org.springframework.context.annotation.Condition
Condition to check whether the Vaadin servlet is mapped to the root ("/*").

In this case a DispatcherServlet is used. It's mapped to the root instead of VaadinServlet and forwards requests to VaadinServlet. If there are other mappings (via Spring endpoints e.g.) then DispatcherServlet makes it possible to handle them properly via those endpoints. Otherwise VaadinServlet will handle all the URLs because it has the highest priority.

Since:
10.0
Author:
Vaadin Ltd
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name of the property that holds the Vaadin servlet url mapping.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates the condition.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getUrlMapping(org.springframework.core.env.Environment environment)
    Gets the url mapping in a way compatible with both plain Spring and Spring Boot.
    static boolean
    Returns true if mapping is the root mapping ("/*").
    boolean
    matches(org.springframework.context.annotation.ConditionContext context, org.springframework.core.type.AnnotatedTypeMetadata metadata)
     

    Methods inherited from class java.lang.Object

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

    • URL_MAPPING_PROPERTY

      public static final String URL_MAPPING_PROPERTY
      Name of the property that holds the Vaadin servlet url mapping.
      See Also:
  • Constructor Details

    • RootMappedCondition

      public RootMappedCondition()
      Creates the condition. Spring instantiates it when evaluating a @Conditional annotation.
  • Method Details

    • matches

      public boolean matches(org.springframework.context.annotation.ConditionContext context, org.springframework.core.type.AnnotatedTypeMetadata metadata)
      Specified by:
      matches in interface org.springframework.context.annotation.Condition
    • getUrlMapping

      public static String getUrlMapping(org.springframework.core.env.Environment environment)
      Gets the url mapping in a way compatible with both plain Spring and Spring Boot.
      Parameters:
      environment - the application environment
      Returns:
      the url mapping or null if none is defined
      Since:
      23.1
    • isRootMapping

      public static boolean isRootMapping(String mapping)
      Returns true if mapping is the root mapping ("/*").

      The mapping is controlled via the vaadin.urlMapping property value. By default it's "/*".

      Parameters:
      mapping - the mapping string to check
      Returns:
      true if mapping is the root mapping and false otherwise