public class RouteRegistry extends Object implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
RouteRegistry.ErrorTargetEntry
A pair of a navigation target for handling exceptions and the exception
type handled by the navigation target.
|
| Modifier | Constructor and Description |
|---|---|
protected |
RouteRegistry()
Creates a new uninitialized route registry.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
errorNavigationTargetsInitialized()
Returns whether this registry has been initialized with error navigation
targets.
|
Optional<RouteRegistry.ErrorTargetEntry> |
getErrorNavigationTarget(Exception exception)
Get a registered navigation target for given exception.
|
static RouteRegistry |
getInstance(javax.servlet.ServletContext servletContext)
Gets the route registry for the given servlet context.
|
Optional<Class<? extends Component>> |
getNavigationTarget(String pathString)
Gets the optional navigation target class for a given Location.
|
Optional<Class<? extends Component>> |
getNavigationTarget(String pathString,
List<String> segments)
Gets the optional navigation target class for a given Location matching
with path segments.
|
Class<?> |
getPwaConfigurationClass()
Gets pwa configuration class.
|
List<RouteData> |
getRegisteredRoutes()
Get the
RouteData for all registered navigation targets. |
Optional<String> |
getTargetUrl(Class<? extends Component> navigationTarget)
Get the url string for given navigation target.
|
Optional<ThemeDefinition> |
getThemeFor(Class<?> navigationTarget,
String path)
Gets the
ThemeDefinition associated with the given navigation
target, if any. |
boolean |
hasNavigationTargets()
Checks whether any navigation targets have been registered.
|
boolean |
hasRoutes()
Check if there are any registered routes.
|
boolean |
hasRouteTo(String pathString)
Checks if the registry contains a route to the given path.
|
boolean |
navigationTargetsInitialized()
Returns whether this registry has been initialized with navigation
targets.
|
void |
setErrorNavigationTargets(Set<Class<? extends Component>> errorNavigationTargets)
Set error handler navigation targets.
|
void |
setNavigationTargets(Set<Class<? extends Component>> navigationTargets)
Registers a set of components as navigation targets.
|
void |
setPwaConfigurationClass(Class<?> pwaClass)
Sets pwa configuration class.
|
protected RouteRegistry()
public static RouteRegistry getInstance(javax.servlet.ServletContext servletContext)
servletContext - the servlet context for which to get a route registry, not
nullnullpublic void setNavigationTargets(Set<Class<? extends Component>> navigationTargets) throws InvalidRouteConfigurationException
Note: Navigation targets can only be set once, i.e. when
navigationTargetsInitialized() is false.
navigationTargets - set of navigation target componentsInvalidRouteConfigurationException - if routing has been configured incorrectlypublic void setErrorNavigationTargets(Set<Class<? extends Component>> errorNavigationTargets)
errorNavigationTargets - error handler navigation targetspublic List<RouteData> getRegisteredRoutes()
RouteData for all registered navigation targets.public boolean errorNavigationTargetsInitialized()
public Optional<RouteRegistry.ErrorTargetEntry> getErrorNavigationTarget(Exception exception)
exception - exception to search error view forpublic Optional<Class<? extends Component>> getNavigationTarget(String pathString)
pathString - the path to get the navigation target for, not nullLocationpublic Optional<Class<? extends Component>> getNavigationTarget(String pathString, List<String> segments)
pathString - path to get navigation target for, not nullsegments - segments given for pathLocationpublic boolean hasRouteTo(String pathString)
pathString - path to get navigation target for, not nullpublic Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)
navigationTarget - navigation target to get registered route for, not
nullpublic boolean navigationTargetsInitialized()
public boolean hasNavigationTargets()
true if at least one navigation target is
registered; otherwise falsepublic boolean hasRoutes()
public Optional<ThemeDefinition> getThemeFor(Class<?> navigationTarget, String path)
ThemeDefinition associated with the given navigation
target, if any. The theme is defined by using the Theme
annotation on the navigation target class.
If no Theme and NoTheme annotation are used, by default
the com.vaadin.flow.theme.lumo.Lumo class is used (if present on
the classpath).
navigationTarget - the navigation target classpath - the resolved route path so we can determine what the rendered
target is forpublic Class<?> getPwaConfigurationClass()
public void setPwaConfigurationClass(Class<?> pwaClass)
AbstractRouteRegistryInitializer.pwaClass - a class that has PWA -annotation, that's to be used in
service initialization.Copyright © 2000–2018 Vaadin Ltd. All rights reserved.