Package com.vaadin.flow.server
Class SessionRouteRegistry
- java.lang.Object
-
- com.vaadin.flow.router.internal.AbstractRouteRegistry
-
- com.vaadin.flow.server.SessionRouteRegistry
-
- All Implemented Interfaces:
RouteRegistry,Serializable
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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.router.internal.AbstractRouteRegistry
AbstractRouteRegistry.Configuration
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RegistrationaddRoutesChangeListener(RoutesChangedListener listener)Adds the given route change listener to the registry.VaadinContextgetContext()Gets the Vaadin context which the registry belongs to.NavigationRouteTargetgetNavigationRouteTarget(String url)Search for a route target using given navigationurlargument.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 theRouteDatafor 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 theRouteTargetcontained in theNavigationRouteTarget.RouteTargetgetRouteTarget(Class<? extends Component> target, RouteParameters parameters)Gets theRouteTargetinstance matching the given target component and route parameters.static RouteRegistrygetSessionRegistry(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, hasMandatoryParameter, 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 for- Returns:
- session registry for given session
-
getRegisteredRoutes
public List<RouteData> getRegisteredRoutes()
Description copied from interface:RouteRegistryGet theRouteDatafor all registered navigation targets.- Specified by:
getRegisteredRoutesin interfaceRouteRegistry- Overrides:
getRegisteredRoutesin 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:
addRoutesChangeListenerin interfaceRouteRegistry- Overrides:
addRoutesChangeListenerin classAbstractRouteRegistry- Parameters:
listener- listener to add- Returns:
- registration to remove the listener
-
getNavigationRouteTarget
public NavigationRouteTarget getNavigationRouteTarget(String url)
Description copied from interface:RouteRegistrySearch for a route target using given navigationurlargument.- Specified by:
getNavigationRouteTargetin interfaceRouteRegistry- Overrides:
getNavigationRouteTargetin classAbstractRouteRegistry- Parameters:
url- the navigation url used to search a route target.- Returns:
- a
NavigationRouteTargetinstance containing theRouteTargetandRouteParametersextracted from theurlargument according with the route configuration.
-
getRouteTarget
public RouteTarget getRouteTarget(Class<? extends Component> target, RouteParameters parameters)
Description copied from interface:RouteRegistryGets theRouteTargetinstance matching the given target component and route parameters.- Specified by:
getRouteTargetin interfaceRouteRegistry- Overrides:
getRouteTargetin classAbstractRouteRegistry- Parameters:
target- a component class which is a navigation target.parameters- parameter values that may be used with given target.- Returns:
- the
RouteTargetinstance matching the given target component and route parameters.
-
getNavigationTarget
public Optional<Class<? extends Component>> getNavigationTarget(String url)
Description copied from interface:RouteRegistryGets the optional navigation target class for a given path. Returns an empty optional if no navigation target corresponds to the given url.- Specified by:
getNavigationTargetin interfaceRouteRegistry- Overrides:
getNavigationTargetin 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:RouteRegistryGets the optional navigation target class for a given Location matching with path segments.- Specified by:
getNavigationTargetin interfaceRouteRegistry- Overrides:
getNavigationTargetin classAbstractRouteRegistry- Parameters:
url- path to get navigation target for, notnullsegments- segments given for path- Returns:
- optional navigation target corresponding to the given location with given segments if any applicable targets found.
- See Also:
Location
-
getTargetUrl
public Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)
Description copied from interface:RouteRegistryGet the url string for given navigation target.- Specified by:
getTargetUrlin interfaceRouteRegistry- Overrides:
getTargetUrlin classAbstractRouteRegistry- Parameters:
navigationTarget- navigation target to get registered route for, notnull- Returns:
Optionalnavigation 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:RouteRegistryGet the url string for given navigation target.- Specified by:
getTargetUrlin interfaceRouteRegistry- Overrides:
getTargetUrlin classAbstractRouteRegistry- Parameters:
navigationTarget- navigation target to get registered route for, notnullparameters- parameters for the target url.- Returns:
Optionalnavigation target url string orOptional.empty()if navigation target was not found
-
getTemplate
public Optional<String> getTemplate(Class<? extends Component> navigationTarget)
Description copied from interface:RouteRegistryGet the main template for given navigation target.In case of annotated target the main template is composed of the
Routeannotation value prefixed by allRoutePrefixvalues of the parentRouterLayouts chain.- Specified by:
getTemplatein interfaceRouteRegistry- Overrides:
getTemplatein classAbstractRouteRegistry- Parameters:
navigationTarget- navigation target to get route definition for, notnull- Returns:
Optionalnavigation target template string orOptional.empty()if navigation target was not found
-
getContext
public VaadinContext getContext()
Description copied from interface:RouteRegistryGets the Vaadin context which the registry belongs to.- Returns:
- the Vaadin context
-
getRouteLayouts
@Deprecated public List<Class<? extends RouterLayout>> getRouteLayouts(String path, Class<? extends Component> navigationTarget)
Deprecated.instead usegetNavigationRouteTarget(String)and retrieve the list of route layouts from theRouteTargetcontained in theNavigationRouteTarget.Description copied from interface:RouteRegistryGet the layout chain for given navigation target on the targeted path.This chain may be pre-defined or generated from annotation data.
- Specified by:
getRouteLayoutsin interfaceRouteRegistry- Overrides:
getRouteLayoutsin classAbstractRouteRegistry- Parameters:
path- path to use for resolving chainnavigationTarget- navigation target to get layout chain for- Returns:
- layout chain of target
- See Also:
RouteTarget.getParentLayouts()
-
-