com.vaadin.flow.server.startup.
Class ApplicationRouteRegistry
- java.lang.Object
-
- com.vaadin.flow.router.internal.AbstractRouteRegistry
-
- com.vaadin.flow.server.startup.ApplicationRouteRegistry
-
All Implemented Interfaces:
public class ApplicationRouteRegistry extends AbstractRouteRegistry
Registry for holding navigation target components found on servlet initialization.
Since:
1.3
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected static class
ApplicationRouteRegistry.ApplicationRouteRegistryWrapper
RouteRegistry wrapper class for storing the ApplicationRouteRegistry.
-
Nested classes/interfaces inherited from class com.vaadin.flow.router.internal.AbstractRouteRegistry
AbstractRouteRegistry.Configuration
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
ApplicationRouteRegistry()
Creates a new uninitialized route registry.
-
Method Summary
All Methods Modifier and Type Method and Description Optional<ErrorTargetEntry>
getErrorNavigationTarget(Exception exception)
Get a registered navigation target for given exception.
static ApplicationRouteRegistry
getInstance(VaadinContext context)
Gets the route registry for the given Vaadin context.
Optional<Class<? extends Component>>
getNavigationTarget(String pathString)
Gets the optional navigation target class for a given path.
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.
protected void
handleInitializedRegistry()
Handles an attempt to initialize already initialized route registry.
boolean
hasNavigationTargets()
Check if there are registered navigation targets in the registry.
void
setErrorNavigationTargets(Set<Class<? extends Component>> errorNavigationTargets)
Set error handler navigation targets.
void
setPwaConfigurationClass(Class<?> pwaClass)
Sets pwa configuration class.
void
setRoute(String path, Class<? extends Component> navigationTarget, List<Class<? extends RouterLayout>> parentChain)
Register a navigation target with specified path and given parent layout chain.
-
Methods inherited from class com.vaadin.flow.router.internal.AbstractRouteRegistry
addErrorTarget, addRoutesChangeListener, clean, configure, fireEvent, getConfiguration, getRegisteredRoutes, getRouteLayouts, getTargetUrl, hasLock, removeRoute, removeRoute, removeRoute, searchByCause, searchBySuperType, update
-
-
-
-
Constructor Detail
-
ApplicationRouteRegistry
protected ApplicationRouteRegistry()
Creates a new uninitialized route registry.
-
-
Method Detail
-
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, notnull
Returns:
a registry instance for the given servlet 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
orRouteAlias
will be ignored in route handling.Specified by:
setRoute
in interfaceRouteRegistry
Overrides:
setRoute
in classAbstractRouteRegistry
Parameters:
path
- path to register navigation target tonavigationTarget
- navigation target to register into session scopeparentChain
- 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)
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.
Parameters:
exception
- exception to search error view forReturns:
optional error target entry corresponding to the given exception
-
getNavigationTarget
public Optional<Class<? extends Component>> getNavigationTarget(String pathString)
Description copied from interface:
RouteRegistry
Gets the optional navigation target class for a given path. Returns an empty optional if no navigation target corresponds to the given path.
Note! If a path has been specifically removed from a registry it will not be served from possible higher lever registries either.
Parameters:
pathString
- the path to get the navigation target for, notnull
Returns:
optional of the navigation target corresponding to the given path
-
getNavigationTarget
public Optional<Class<? extends Component>> getNavigationTarget(String pathString, List<String> segments)
Description copied from interface:
RouteRegistry
Gets the optional navigation target class for a given Location matching with path segments.
Note! If a path has been specifically removed from a registry it will not be served from possible higher lever registries either.
Parameters:
pathString
- path to get navigation target for, notnull
segments
- segments given for pathReturns:
optional navigation target corresponding to the given location with given segments if any applicable targets found.
See Also:
-
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.
-
handleInitializedRegistry
protected void handleInitializedRegistry()
Handles an attempt to initialize already initialized route registry.
-
-