Interface RouteRegistry
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractRouteRegistry,ApplicationRouteRegistry,SessionRouteRegistry
public interface RouteRegistry extends Serializable
The RouteRegistry interface class that gives the out facing usage needs for a route registry implementation.This is used by
Routerwhen resolving navigation and layout chain population.- Since:
- 1.3
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description RegistrationaddRoutesChangeListener(RoutesChangedListener listener)Adds the given route change listener to the registry.voidclean()Clear all registered routes from 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.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.booleanhasMandatoryParameter(Class<? extends Component> navigationTarget)Check if the given navigationTarget requires parameters.voidremoveRoute(Class<? extends Component> navigationTarget)Remove the given navigation target route registration.voidremoveRoute(String path)Remove the registration for given path.voidremoveRoute(String path, Class<? extends Component> navigationTarget)Remove navigationTarget for the path.voidsetRoute(String path, Class<? extends Component> navigationTarget, List<Class<? extends RouterLayout>> parentChain)Register a navigation target with specified path and given parent layout chain.voidupdate(Command command)Block updates to the registry configuration from other threads until update command has completed.
-
-
-
Method Detail
-
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. AnyParentLayout,RouteorRouteAliaswill 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 target- Throws:
InvalidRouteConfigurationException- thrown if exact route already defined in this scope
-
removeRoute
void removeRoute(Class<? extends Component> navigationTarget)
Remove the given navigation target route registration.Note! this will remove target route and if possible any
RouteAliasroute that can be found for the class.- Parameters:
navigationTarget- navigation target class to remove
-
removeRoute
void removeRoute(String path)
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
void removeRoute(String path, Class<? extends Component> navigationTarget)
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 theRouteannotation 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
List<RouteData> getRegisteredRoutes()
Get theRouteDatafor all registered navigation targets.- Returns:
- list of routes available for this registry
-
getNavigationRouteTarget
NavigationRouteTarget getNavigationRouteTarget(String url)
Search for a route target using given navigationurlargument.- Parameters:
url- the navigation url used to search a route target.- Returns:
- a
NavigationRouteTargetinstance containing theRouteTargetandRouteParametersextracted from theurlargument according with the route configuration.
-
getRouteTarget
RouteTarget getRouteTarget(Class<? extends Component> target, RouteParameters parameters)
Gets theRouteTargetinstance 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
RouteTargetinstance matching the given target component and route parameters.
-
getNavigationTarget
Optional<Class<? extends Component>> getNavigationTarget(String url)
Gets the optional navigation target class for a given path. Returns an empty optional if no navigation target corresponds to the given url.- Parameters:
url- the path to get the navigation target for, notnull- Returns:
- optional of the navigation target corresponding to the given path
-
getNavigationTarget
Optional<Class<? extends Component>> getNavigationTarget(String url, List<String> segments)
Gets the optional navigation target class for a given Location matching with path segments.- 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
Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)
Get the url string for given navigation target.- Parameters:
navigationTarget- navigation target to get registered route for, notnull- Returns:
Optionalnavigation 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, notnullparameters- parameters for the target url.- Returns:
Optionalnavigation target url string orOptional.empty()if navigation target was not found
-
getTemplate
Optional<String> getTemplate(Class<? extends Component> navigationTarget)
Get 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.- Parameters:
navigationTarget- navigation target to get route definition for, notnull- Returns:
Optionalnavigation target template string orOptional.empty()if navigation target was not found
-
getRouteLayouts
@Deprecated 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.Get the layout chain for given navigation target on the targeted path.This chain may be pre-defined or generated from annotation data.
- Parameters:
path- path to use for resolving chainnavigationTarget- navigation target to get layout chain for- Returns:
- layout chain of target
- See Also:
RouteTarget.getParentLayouts()
-
update
void update(Command command)
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
Registration addRoutesChangeListener(RoutesChangedListener listener)
Adds the given route change listener to the registry.- Parameters:
listener- listener to be informed on route changes- Returns:
- 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
boolean hasMandatoryParameter(Class<? extends Component> navigationTarget)
Check if the given navigationTarget requires parameters.- Parameters:
navigationTarget- navigation target to check- Returns:
trueif parameters are required- Throws:
NotFoundException- if given navigation target is not registered
-
-