public abstract class AbstractRouteRegistry extends Object implements RouteRegistry
For internal use only. May be renamed or removed in a future release.
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractRouteRegistry.Configuration
Configuration interface to use for updating the configuration entity.
|
| Constructor and Description |
|---|
AbstractRouteRegistry() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addErrorTarget(Class<? extends Component> target,
Map<Class<? extends Exception>,Class<? extends Component>> exceptionTargetsMap)
Add the given error target to the exceptionTargetMap.
|
Registration |
addRoutesChangeListener(RoutesChangedListener listener)
Adds the given route change listener to the registry.
|
void |
clean()
Clear all registered routes from the registry.
|
protected void |
configure(AbstractRouteRegistry.Configuration command)
Thread-safe update of the RouteConfiguration.
|
protected void |
fireEvent(RoutesChangedEvent routeChangedEvent)
Fire routes changed event to all registered listeners.
|
ConfiguredRoutes |
getConfiguration()
Get the current valid configuration.
|
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 use
getNavigationRouteTarget(String) and
retrieve the list of route layouts from the
RouteTarget contained in the
NavigationRouteTarget. |
RouteTarget |
getRouteTarget(Class<? extends Component> target,
RouteParameters parameters)
Gets the
RouteTarget instance 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.
|
protected boolean |
hasLock() |
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.
|
protected Optional<ErrorTargetEntry> |
searchByCause(Exception exception)
Get the exception handler for given exception or recurse by exception
cause until possible exception with handler found.
|
protected Optional<ErrorTargetEntry> |
searchBySuperType(Throwable exception)
Search given exception super classes to get exception handler for if any
exist.
|
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.
|
protected void configure(AbstractRouteRegistry.Configuration command)
command - command that will mutate the configuration copy.public void update(Command command)
RouteRegistryAny other thread trying to configure current registry will be blocked until the update has released all the locks.
update in interface RouteRegistrycommand - command to execute for the updateprotected void fireEvent(RoutesChangedEvent routeChangedEvent)
routeChangedEvent - event containing changespublic Registration addRoutesChangeListener(RoutesChangedListener listener)
RouteRegistryaddRoutesChangeListener in interface RouteRegistrylistener - listener to be informed on route changesprotected boolean hasLock()
public ConfiguredRoutes getConfiguration()
Note! there may exist a possibility that someone updates this while it's being read, but the given configuration is valid at the given point in time.
public List<RouteData> getRegisteredRoutes()
RouteRegistryRouteData for all registered navigation targets.getRegisteredRoutes in interface RouteRegistry@Deprecated public List<Class<? extends RouterLayout>> getRouteLayouts(String path, Class<? extends Component> navigationTarget)
getNavigationRouteTarget(String) and
retrieve the list of route layouts from the
RouteTarget contained in the
NavigationRouteTarget.RouteRegistryThis chain may be pre-defined or generated from annotation data.
getRouteLayouts in interface RouteRegistrypath - path to use for resolving chainnavigationTarget - navigation target to get layout chain forRouteTarget.getParentLayouts()public Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)
RouteRegistrygetTargetUrl in interface RouteRegistrynavigationTarget - navigation target to get registered route for, not
nullOptional navigation target url string or
Optional.empty() if navigation target was not foundpublic Optional<String> getTargetUrl(Class<? extends Component> navigationTarget, RouteParameters parameters)
RouteRegistrygetTargetUrl in interface RouteRegistrynavigationTarget - navigation target to get registered route for, not
nullparameters - parameters for the target url.Optional navigation target url string or
Optional.empty() if navigation target was not foundpublic Optional<String> getTemplate(Class<? extends Component> navigationTarget)
RouteRegistry
In case of annotated target the main template is composed of the
Route annotation value prefixed by all RoutePrefix values
of the parent RouterLayouts chain.
getTemplate in interface RouteRegistrynavigationTarget - navigation target to get route definition for, not
nullOptional navigation target template string or
Optional.empty() if navigation target was not foundpublic void setRoute(String path, Class<? extends Component> navigationTarget, List<Class<? extends RouterLayout>> parentChain)
RouteRegistryParentLayout, Route or RouteAlias will
be ignored in route handling.setRoute in interface RouteRegistrypath - path to register navigation target tonavigationTarget - navigation target to register into session scopeparentChain - chain of parent layouts that should be used with this targetpublic void removeRoute(Class<? extends Component> navigationTarget)
RouteRegistry
Note! this will remove target route and if possible any
RouteAlias route that can be found for the class.
removeRoute in interface RouteRegistrynavigationTarget - navigation target class to removepublic void removeRoute(String path)
RouteRegistry
In case navigationTarget is a
HasUrlParameter, path argument needs to
include the parameter placeholder which is added automatically.
Otherwise, using RouteRegistry.removeRoute(String, Class) is preferred in such
a case.
removeRoute in interface RouteRegistrypath - path for which to remove the navigation target.public void removeRoute(String path, Class<? extends Component> navigationTarget)
RouteRegistryThis 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 the Route annotation or as it was
registered using RouteRegistry.setRoute(String, Class, List), without the
parameter placeholder which is automatically added.
removeRoute in interface RouteRegistrypath - path to remove from registrynavigationTarget - path navigation target to removepublic void clean()
RouteRegistryclean in interface RouteRegistrypublic NavigationRouteTarget getNavigationRouteTarget(String url)
RouteRegistryurl
argument.getNavigationRouteTarget in interface RouteRegistryurl - the navigation url used to search a route target.NavigationRouteTarget instance containing the
RouteTarget and RouteParameters extracted from
the url argument according with the route
configuration.public RouteTarget getRouteTarget(Class<? extends Component> target, RouteParameters parameters)
RouteRegistryRouteTarget instance matching the given target component
and route parameters.getRouteTarget in interface RouteRegistrytarget - a component class which is a navigation target.parameters - parameter values that may be used with given target.RouteTarget instance matching the given target
component and route parameters.public Optional<Class<? extends Component>> getNavigationTarget(String url)
RouteRegistrygetNavigationTarget in interface RouteRegistryurl - the path to get the navigation target for, not nullpublic Optional<Class<? extends Component>> getNavigationTarget(String url, List<String> segments)
RouteRegistrygetNavigationTarget in interface RouteRegistryurl - path to get navigation target for, not nullsegments - segments given for pathLocationprotected void addErrorTarget(Class<? extends Component> target, Map<Class<? extends Exception>,Class<? extends Component>> exceptionTargetsMap)
target - error handler targetexceptionTargetsMap - map of existing error handlersInvalidRouteConfigurationException - if trying to add a non related exception handler for which a
handler already existsprotected Optional<ErrorTargetEntry> searchByCause(Exception exception)
exception - exception to get handler forprotected Optional<ErrorTargetEntry> searchBySuperType(Throwable exception)
exception - exception to get handler forCopyright © 2025. All rights reserved.