Class ApplicationRouteRegistry

java.lang.Object
com.vaadin.flow.router.internal.AbstractRouteRegistry
com.vaadin.flow.server.startup.ApplicationRouteRegistry
All Implemented Interfaces:
ErrorRouteRegistry, RouteRegistry, Serializable

public class ApplicationRouteRegistry extends AbstractRouteRegistry implements ErrorRouteRegistry
Registry for holding navigation target components found on servlet initialization.
Since:
1.3
See Also:
  • Constructor Details

    • ApplicationRouteRegistry

      protected ApplicationRouteRegistry(VaadinContext context)
      Creates a new uninitialized route registry.
  • Method Details

    • getInstance

      public static ApplicationRouteRegistry getInstance(VaadinContext context)
      Gets the route registry for the given Vaadin context. If the Vaadin context has no route registry, a new instance is created and assigned to the context.
      Parameters:
      context - the vaadin context for which to get a route registry, not null
      Returns:
      a registry instance for the given context, not null
    • setRoute

      public void setRoute(String path, Class<? extends Component> navigationTarget, List<Class<? extends RouterLayout>> parentChain)
      Description copied from interface: RouteRegistry
      Register a navigation target with specified path and given parent layout chain. Any ParentLayout, Route or RouteAlias will be ignored in route handling.
      Specified by:
      setRoute in interface RouteRegistry
      Overrides:
      setRoute in class AbstractRouteRegistry
      Parameters:
      path - path to register navigation target to
      navigationTarget - navigation target to register into session scope
      parentChain - chain of parent layouts that should be used with this target
    • setErrorNavigationTargets

      public void setErrorNavigationTargets(Set<Class<? extends Component>> errorNavigationTargets)
      Set error handler navigation targets.

      This can also be used to add error navigation targets that override existing targets. Note! The overriding targets need to be extending the existing target or they will throw.

      Parameters:
      errorNavigationTargets - error handler navigation targets
    • getErrorNavigationTarget

      public Optional<ErrorTargetEntry> getErrorNavigationTarget(Exception exception)
      Description copied from interface: ErrorRouteRegistry
      Get a registered navigation target for given exception. First we will search for a matching cause for in the exception chain and if no match found search by extended type.
      Specified by:
      getErrorNavigationTarget in interface ErrorRouteRegistry
      Parameters:
      exception - exception to search error view for
      Returns:
      optional error target entry corresponding to the given exception
    • hasNavigationTargets

      public boolean hasNavigationTargets()
      Check if there are registered navigation targets in the registry.
      Returns:
      true if any navigation are registered
    • getPwaConfigurationClass

      public Class<?> getPwaConfigurationClass()
      Gets pwa configuration class.
      Returns:
      a class that has PWA-annotation.
    • setPwaConfigurationClass

      public void setPwaConfigurationClass(Class<?> pwaClass)
      Sets pwa configuration class. Should be set along with setRoutes, for scanning of proper pwa configuration class is done along route scanning. See AbstractRouteRegistryInitializer.
      Parameters:
      pwaClass - a class that has PWA -annotation, that's to be used in service initialization.
    • getContext

      public VaadinContext getContext()
      Description copied from interface: RouteRegistry
      Gets the Vaadin context which the registry belongs to.
      Specified by:
      getContext in interface RouteRegistry
      Returns:
      the Vaadin context
    • handleInitializedRegistry

      protected void handleInitializedRegistry()
      Handles an attempt to initialize already initialized route registry.