com.vaadin.flow.server.
Class SessionRouteRegistry
- java.lang.Object
-
- com.vaadin.flow.router.internal.AbstractRouteRegistry
-
- com.vaadin.flow.server.SessionRouteRegistry
-
All Implemented Interfaces:
public class SessionRouteRegistry extends AbstractRouteRegistry
SessionRouteRegistry is a mutable route registry that is valid in the scope of VaadinSession. Routes can be added and removed from this registry and any overlap with the registered routes between session and global scope will be handled so that session scope paths overrides global paths.
Since:
1.3
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.router.internal.AbstractRouteRegistry
AbstractRouteRegistry.Configuration
-
-
Method Summary
All Methods Modifier and Type Method and Description Registration
addRoutesChangeListener(RoutesChangedListener listener)
Adds the given route change listener to the registry.
NavigationRouteTarget
getNavigationRouteTarget(String url)
Search for a route target using given navigation
url
argument.Optional<Class<? extends Component>>
getNavigationTarget(String url)
Gets the optional navigation target class for a given path.
Optional<Class<? extends Component>>
getNavigationTarget(String url, List<String> segments)
Gets the optional navigation target class for a given Location matching with path segments.
List<RouteData>
getRegisteredRoutes()
Get the
RouteData
for all registered navigation targets.List<Class<? extends RouterLayout>>
getRouteLayouts(String path, Class<? extends Component> navigationTarget)
Deprecated.
instead usegetNavigationRouteTarget(String)
and retrieve the list of route layouts from theRouteTarget
contained in theNavigationRouteTarget
.RouteTarget
getRouteTarget(Class<? extends Component> target, RouteParameters parameters)
Gets the
RouteTarget
instance matching the given target component and route parameters.static RouteRegistry
getSessionRegistry(VaadinSession session)
Get the session registry for VaadinSession.
Optional<String>
getTargetUrl(Class<? extends Component> navigationTarget)
Get the url string for given navigation target.
Optional<String>
getTargetUrl(Class<? extends Component> navigationTarget, RouteParameters parameters)
Get the url string for given navigation target.
Optional<String>
getTemplate(Class<? extends Component> navigationTarget)
Get the main template for given navigation target.
-
Methods inherited from class com.vaadin.flow.router.internal.AbstractRouteRegistry
addErrorTarget, clean, configure, fireEvent, getConfiguration, hasLock, removeRoute, removeRoute, removeRoute, searchByCause, searchBySuperType, setRoute, update
-
-
-
-
Method Detail
-
getSessionRegistry
public static RouteRegistry getSessionRegistry(VaadinSession session)
Get the session registry for VaadinSession. If no SessionRegistry exists then one will be created for given VaadinSession.
Parameters:
session
- vaadin session to get registry forReturns:
session registry for given session
-
getRegisteredRoutes
public List<RouteData> getRegisteredRoutes()
Description copied from interface:
RouteRegistry
Get the
RouteData
for all registered navigation targets.Specified by:
getRegisteredRoutes
in interfaceRouteRegistry
Overrides:
getRegisteredRoutes
in classAbstractRouteRegistry
Returns:
list of routes available for this registry
-
addRoutesChangeListener
public Registration addRoutesChangeListener(RoutesChangedListener listener)
Adds the given route change listener to the registry.
For the session scoped registry also changes to the application scoped registry will be delegated to the listener if the added or removed route was not masked by a registration in the session scope.
Specified by:
addRoutesChangeListener
in interfaceRouteRegistry
Overrides:
addRoutesChangeListener
in classAbstractRouteRegistry
Parameters:
listener
- listener to addReturns:
registration to remove the listener
-
getNavigationRouteTarget
public NavigationRouteTarget getNavigationRouteTarget(String url)
Description copied from interface:
RouteRegistry
Search for a route target using given navigation
url
argument.Specified by:
getNavigationRouteTarget
in interfaceRouteRegistry
Overrides:
getNavigationRouteTarget
in classAbstractRouteRegistry
Parameters:
url
- the navigation url used to search a route target.Returns:
a
NavigationRouteTarget
instance containing theRouteTarget
andRouteParameters
extracted from theurl
argument according with the route configuration.
-
getRouteTarget
public RouteTarget getRouteTarget(Class<? extends Component> target, RouteParameters parameters)
Description copied from interface:
RouteRegistry
Gets the
RouteTarget
instance matching the given target component and route parameters.Specified by:
getRouteTarget
in interfaceRouteRegistry
Overrides:
getRouteTarget
in classAbstractRouteRegistry
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.
-
getNavigationTarget
public Optional<Class<? extends Component>> getNavigationTarget(String url)
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 url.
Specified by:
getNavigationTarget
in interfaceRouteRegistry
Overrides:
getNavigationTarget
in classAbstractRouteRegistry
Parameters:
url
- 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 url, List<String> segments)
Description copied from interface:
RouteRegistry
Gets the optional navigation target class for a given Location matching with path segments.
Specified by:
getNavigationTarget
in interfaceRouteRegistry
Overrides:
getNavigationTarget
in classAbstractRouteRegistry
Parameters:
url
- 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:
-
getTargetUrl
public Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)
Description copied from interface:
RouteRegistry
Get the url string for given navigation target.
Specified by:
getTargetUrl
in interfaceRouteRegistry
Overrides:
getTargetUrl
in classAbstractRouteRegistry
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
public Optional<String> getTargetUrl(Class<? extends Component> navigationTarget, RouteParameters parameters)
Description copied from interface:
RouteRegistry
Get the url string for given navigation target.
Specified by:
getTargetUrl
in interfaceRouteRegistry
Overrides:
getTargetUrl
in classAbstractRouteRegistry
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
public Optional<String> getTemplate(Class<? extends Component> navigationTarget)
Description copied from interface:
RouteRegistry
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.Specified by:
getTemplate
in interfaceRouteRegistry
Overrides:
getTemplate
in classAbstractRouteRegistry
Parameters:
navigationTarget
- navigation target to get route definition for, notnull
Returns:
Optional
navigation target template string orOptional.empty()
if navigation target was not found
-
getRouteLayouts
@Deprecated public List<Class<? extends RouterLayout>> getRouteLayouts(String path, Class<? extends Component> navigationTarget)
Deprecated. instead use
getNavigationRouteTarget(String)
and retrieve the list of route layouts from theRouteTarget
contained in theNavigationRouteTarget
.Description copied from interface:
RouteRegistry
Get the layout chain for given navigation target on the targeted path.
This chain may be pre-defined or generated from annotation data.
Specified by:
getRouteLayouts
in interfaceRouteRegistry
Overrides:
getRouteLayouts
in classAbstractRouteRegistry
Parameters:
path
- path to use for resolving chainnavigationTarget
- navigation target to get layout chain forReturns:
layout chain of target
See Also:
-
-