com.vaadin.flow.server.
Interface RouteRegistry
All Superinterfaces:
All Known Implementing Classes:
AbstractRouteRegistry
, ApplicationRouteRegistry
, SessionRouteRegistry
The RouteRegistry interface class that gives the out facing usage needs for a route registry implementation.
This is used by Router
when resolving navigation and layout chain
population.
Since:
1.3
-
Method Summary
Modifier and TypeMethodDescriptionaddRoutesChangeListener
(RoutesChangedListener listener) Adds the given route change listener to the registry.
void
clean()
Clear all registered routes from the registry.
Gets the Vaadin context which the registry belongs to.
Class<? extends RouterLayout>
Get the layout component for the current path.
Search for a route target using given navigation
url
argument.Gets the optional navigation target class for a given path.
getNavigationTarget
(String url, List<String> segments) Gets the optional navigation target class for a given Location matching with path segments.
getRegisteredAccessibleMenuRoutes
(VaadinRequest vaadinRequest, Collection<BeforeEnterListener> accessControls) Get the
RouteData
for all accessible registered navigation targets with a menu information.Get the
RouteData
for all registered navigation targets.getRouteTarget
(Class<? extends Component> target, RouteParameters parameters) Gets the
RouteTarget
instance matching the given target component and route parameters.getTargetUrl
(Class<? extends Component> navigationTarget) Get the url string for given navigation target.
getTargetUrl
(Class<? extends Component> navigationTarget, RouteParameters parameters) Get the url string for given navigation target.
getTemplate
(Class<? extends Component> navigationTarget) Get the main template for given navigation target.
boolean
Check if a layout component has been registered for the current path.
boolean
hasMandatoryParameter
(Class<? extends Component> navigationTarget) Check if the given navigationTarget requires parameters.
void
removeRoute
(Class<? extends Component> navigationTarget) Remove the given navigation target route registration.
void
removeRoute
(String path) Remove the registration for given path.
void
removeRoute
(String path, Class<? extends Component> navigationTarget) Remove navigationTarget for the path.
void
setLayout
(Class<? extends RouterLayout> layout) Set a layout component for use as automatic layout.
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.
void
Block updates to the registry configuration from other threads until update command has completed.
-
Method Details
-
setRoute
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. Any
ParentLayout
,Route
orRouteAlias
will be ignored in route handling.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 targetThrows:
InvalidRouteConfigurationException
- thrown if exact route already defined in this scope -
removeRoute
Remove the given navigation target route registration.
Note! this will remove target route and if possible any
RouteAlias
route that can be found for the class.Parameters:
navigationTarget
- navigation target class to remove -
removeRoute
Remove the registration for given path.
In case navigationTarget is a
HasUrlParameter
, path argument needs to include the parameter placeholder which is added automatically. Otherwise, usingremoveRoute(String, Class)
is preferred in such a case.Parameters:
path
- path for which to remove the navigation target. -
removeRoute
Remove navigationTarget for the path.
This method will check if indeed navigationTarget is registered with path.
In case navigationTarget is a
HasUrlParameter
, the path needs to be specified exactly as it is in theRoute
annotation or as it was registered usingsetRoute(String, Class, List)
, without the parameter placeholder which is automatically added.Parameters:
path
- path to remove from registrynavigationTarget
- path navigation target to remove -
getRegisteredRoutes
Get the
RouteData
for all registered navigation targets.Returns:
list of routes available for this registry
-
getRegisteredAccessibleMenuRoutes
List<RouteData> getRegisteredAccessibleMenuRoutes(VaadinRequest vaadinRequest, Collection<BeforeEnterListener> accessControls) Get the
RouteData
for all accessible registered navigation targets with a menu information. Access checking depends on the activeVaadinService
andVaadinRequest
and the given collection of access controls.Parameters:
vaadinRequest
- the request to check access foraccessControls
- the access controls to use for checking accessReturns:
list of accessible menu routes available for this registry
-
getRouteTarget
Gets the
RouteTarget
instance matching the given target component and route parameters.Parameters:
target
- a component class which is a navigation target.parameters
- parameter values that may be used with given target.Returns:
the
RouteTarget
instance matching the given target component and route parameters. -
getTargetUrl
Get the url string for given navigation target.
Parameters:
navigationTarget
- navigation target to get registered route for, notnull
Returns:
Optional
navigation target url string orOptional.empty()
if navigation target was not found -
getTargetUrl
Optional<String> getTargetUrl(Class<? extends Component> navigationTarget, RouteParameters parameters) Get the url string for given navigation target.
Parameters:
navigationTarget
- navigation target to get registered route for, notnull
parameters
- parameters for the target url.Returns:
Optional
navigation target url string orOptional.empty()
if navigation target was not found -
getTemplate
Get the main template for given navigation target.
In case of annotated target the main template is composed of the
Route
annotation value prefixed by allRoutePrefix
values of the parentRouterLayout
s chain.Parameters:
navigationTarget
- navigation target to get route definition for, notnull
Returns:
Optional
navigation target template string orOptional.empty()
if navigation target was not found -
update
Block updates to the registry configuration from other threads until update command has completed. This makes the command changes atomic for the registry as no one else can change the registry state during the command.
Any other thread trying to configure current registry will be blocked until the update has released all the locks.
Parameters:
command
- command to execute for the update -
addRoutesChangeListener
Adds the given route change listener to the registry.
Parameters:
listener
- listener to be informed on route changesReturns:
registration to remove the listener
-
clean
void clean()Clear all registered routes from the registry.
-
getContext
VaadinContext getContext()Gets the Vaadin context which the registry belongs to.
Returns:
the Vaadin context
-
hasMandatoryParameter
Check if the given navigationTarget requires parameters.
Parameters:
navigationTarget
- navigation target to checkReturns:
true
if parameters are requiredThrows:
NotFoundException
- if given navigation target is not registered -
setLayout
Set a layout component for use as automatic layout.
Parameters:
layout
-RouterLayout
class -
getLayout
Get the layout component for the current path.
Parameters:
path
- current pathReturns:
RouterLayout
component or null -
hasLayout
Check if a layout component has been registered for the current path.
Parameters:
path
- current pathReturns:
true
if layout exists
-