public interface RouteRegistry extends Serializable
This is used by Router
when resolving navigation and layout chain
population.
Modifier and Type | Method and Description |
---|---|
Registration |
addRoutesChangeListener(RoutesChangedListener listener)
Adds the given route change listener to the registry.
|
void |
clean()
Clear all registered routes from the registry.
|
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.
|
List<RouteData> |
getRegisteredRoutes()
Get the
RouteData for all registered navigation targets. |
List<Class<? extends RouterLayout>> |
getRouteLayouts(String path,
Class<? extends Component> navigationTarget)
Get the layout chain for given navigation target on the targeted path.
|
Optional<String> |
getTargetUrl(Class<? extends Component> navigationTarget)
Get the url string for given navigation target.
|
void |
removeRoute(Class<? extends Component> navigationTarget)
Remove the given navigation target route registration.
|
void |
removeRoute(String path)
Remove all registrations for given path.
|
void |
removeRoute(String path,
Class<? extends Component> navigationTarget)
Remove only the specified navigationTarget from the path and not the
whole path if other targets exist for path.
|
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 |
update(Command command)
Block updates to the registry configuration from other threads until
update command has completed.
|
void setRoute(String path, Class<? extends Component> navigationTarget, List<Class<? extends RouterLayout>> parentChain)
ParentLayout
, Route
or RouteAlias
will
be ignored in route handling.path
- path to register navigation target tonavigationTarget
- navigation target to register into session scopeparentChain
- chain of parent layouts that should be used with this targetInvalidRouteConfigurationException
- thrown if exact route already defined in this scopevoid removeRoute(Class<? extends Component> navigationTarget)
Note! this will remove target route and if possible any
RouteAlias
route that can be found for the class.
navigationTarget
- navigation target class to removevoid removeRoute(String path)
E.g. path "home" contains HomeView and DetailsView[String path param] both will be removed.
Note! The restored path will be the first found match for all paths that are registered.
path
- path for which to remove all navigation targetsvoid removeRoute(String path, Class<? extends Component> navigationTarget)
This will leave any other targets for path e.g. removing the wildcard path will still leave the optional target.
Note! If another path exists for the removed navigation target it will get a new main path so it can still get a resolved url. The restored path will be the first found match for all paths that are registered.
path
- path to remove from registrynavigationTarget
- path navigation target to removeList<RouteData> getRegisteredRoutes()
RouteData
for all registered navigation targets.Optional<Class<? extends Component>> getNavigationTarget(String pathString)
Note! If a path has been specifically removed from a registry it will not be served from possible higher lever registries either.
pathString
- the path to get the navigation target for, not null
Optional<Class<? extends Component>> getNavigationTarget(String pathString, List<String> segments)
Note! If a path has been specifically removed from a registry it will not be served from possible higher lever registries either.
pathString
- path to get navigation target for, not null
segments
- segments given for pathLocation
Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)
Will return Optional.empty is navigation target was not found.
navigationTarget
- navigation target to get registered route for, not
null
List<Class<? extends RouterLayout>> getRouteLayouts(String path, Class<? extends Component> navigationTarget)
This chain may be pre-defined or generated from annotation data.
path
- path to use for resolving chainnavigationTarget
- navigation target to get layout chain forvoid update(Command command)
Any other thread trying to configure current registry will be blocked until the update has released all the locks.
command
- command to execute for the updateRegistration addRoutesChangeListener(RoutesChangedListener listener)
listener
- listener to be informed on route changesvoid clean()
Copyright © 2020. All rights reserved.