public abstract class AbstractRouteRegistry extends Object implements RouteRegistry
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.
|
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.
|
protected boolean |
hasLock() |
void |
removeRoute(Class<? extends Component> routeTarget)
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.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getNavigationTarget, getNavigationTarget
protected void configure(AbstractRouteRegistry.Configuration command)
command
- command that will mutate the configuration copy.public void update(Command command)
RouteRegistry
Any other thread trying to configure current registry will be blocked until the update has released all the locks.
update
in interface RouteRegistry
command
- command to execute for the updateprotected void fireEvent(RoutesChangedEvent routeChangedEvent)
routeChangedEvent
- event containing changespublic Registration addRoutesChangeListener(RoutesChangedListener listener)
RouteRegistry
addRoutesChangeListener
in interface RouteRegistry
listener
- 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()
RouteRegistry
RouteData
for all registered navigation targets.getRegisteredRoutes
in interface RouteRegistry
public List<Class<? extends RouterLayout>> getRouteLayouts(String path, Class<? extends Component> navigationTarget)
RouteRegistry
This chain may be pre-defined or generated from annotation data.
getRouteLayouts
in interface RouteRegistry
path
- path to use for resolving chainnavigationTarget
- navigation target to get layout chain forpublic Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)
RouteRegistry
Will return Optional.empty is navigation target was not found.
getTargetUrl
in interface RouteRegistry
navigationTarget
- navigation target to get registered route for, not
null
public void setRoute(String path, Class<? extends Component> navigationTarget, List<Class<? extends RouterLayout>> parentChain)
RouteRegistry
ParentLayout
, Route
or RouteAlias
will
be ignored in route handling.setRoute
in interface RouteRegistry
path
- 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> routeTarget)
RouteRegistry
Note! this will remove target route and if possible any
RouteAlias
route that can be found for the class.
removeRoute
in interface RouteRegistry
routeTarget
- navigation target class to removepublic void removeRoute(String path)
RouteRegistry
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.
removeRoute
in interface RouteRegistry
path
- path for which to remove all navigation targetspublic void removeRoute(String path, Class<? extends Component> navigationTarget)
RouteRegistry
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.
removeRoute
in interface RouteRegistry
path
- path to remove from registrynavigationTarget
- path navigation target to removepublic void clean()
RouteRegistry
clean
in interface RouteRegistry
protected 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 © 2020. All rights reserved.