Class PathRoutingLink<A,B,C extends PathRoute<A>,D extends PathRoute.Extractor<A,C,D>>
- Type Parameters:
A
- the resource typeB
- the input typeC
- the path route typeD
- the path route extractor type
A RoutingLink
implementation resolving resources by matching the path in an input.
- Since:
- 1.12
- Author:
- Jeremy Kuhn
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.inverno.mod.http.base.router.RoutingLink
RoutingLink.ChainBuilder<A,
B, C extends Route<A>, D extends RouteExtractor<A, C>> -
Constructor Summary
ConstructorDescriptionCreates a terminal path routing link.PathRoutingLink
(Supplier<RoutingLink<A, B, C, D>> nextLinkFactory) Creates a path routing link in a routing chain. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Determines whether the link can link the specified route.protected void
extractLinks
(D routeExtractor) Populates the specified route extractor with the criteria managed by the link.protected RoutingLink
<A, B, C, D> Returns the next link in the routing chain that is matching the specified route.protected Collection
<RoutingLink<A, B, C, D>> getLinks()
Returns all links bound to the link.protected abstract String
getNormalizedPath
(B input) Extracts the absolute normalized path from the input.protected RoutingLink
<A, B, C, D> getOrSetLink
(C route) Returns or sets the next link in the routing chain that is matching the specified route.protected void
Refreshes enabled links.protected void
removeLink
(C route) Removes the link matching the specified route.resolveAllLink
(B input) Resolves all links matching the specified input.protected RoutingLink
<A, B, C, D> resolveLink
(B input) Resolves the link best matching the specified input.protected abstract void
setPathParameters
(B input, Map<String, String> parameters) Injects the parameters extracted when matching the path using apath pattern
in the input.Methods inherited from class io.inverno.mod.http.base.router.RoutingLink
bestMatchingRoutingLink, createLink, currentOrErrorRoutingLink, disableRoute, enableRoute, extractRoutes, isEnabled, link, removeRoute, resolve, resolveAll, setRoute
-
Constructor Details
-
PathRoutingLink
public PathRoutingLink()Creates a terminal path routing link.
-
PathRoutingLink
Creates a path routing link in a routing chain.
- Parameters:
nextLinkFactory
- the next routing link factory
-
-
Method Details
-
getNormalizedPath
Extracts the absolute normalized path from the input.
- Parameters:
input
- an input- Returns:
- an absolute normalized path
-
setPathParameters
Injects the parameters extracted when matching the path using a
path pattern
in the input.- Parameters:
input
- an inputparameters
- the extracted parameters
-
canLink
Description copied from class:RoutingLink
Determines whether the link can link the specified route.
A route is linkable by a link when it defines a criteria handled by the link so basically when the link is able to route an input based on that particular criteria (e.g. a path, an HTTP method...).
-
getLink
Description copied from class:RoutingLink
Returns the next link in the routing chain that is matching the specified route.
-
getOrSetLink
Description copied from class:RoutingLink
Returns or sets the next link in the routing chain that is matching the specified route.
If there is no link matching the route, a new link shall be created and set in the routing chain.
- Specified by:
getOrSetLink
in classRoutingLink<A,
B, C extends PathRoute<A>, D extends PathRoute.Extractor<A, C, D>> - Parameters:
route
- a route- Returns:
- the next routing link in the routing chain
-
getLinks
Description copied from class:RoutingLink
Returns all links bound to the link.
-
removeLink
Description copied from class:RoutingLink
Removes the link matching the specified route.
- Specified by:
removeLink
in classRoutingLink<A,
B, C extends PathRoute<A>, D extends PathRoute.Extractor<A, C, D>> - Parameters:
route
- a route
-
refreshEnabled
protected void refreshEnabled()Description copied from class:RoutingLink
Refreshes enabled links.
This method is invoked after a change in the routing chain in order to optimize the resource resolution process by identifying disabled links as close as possible from the beginning of the chain.
- Specified by:
refreshEnabled
in classRoutingLink<A,
B, C extends PathRoute<A>, D extends PathRoute.Extractor<A, C, D>>
-
extractLinks
Description copied from class:RoutingLink
Populates the specified route extractor with the criteria managed by the link.
This basically comes down to extracting the links managed by the link.
- Specified by:
extractLinks
in classRoutingLink<A,
B, C extends PathRoute<A>, D extends PathRoute.Extractor<A, C, D>> - Parameters:
routeExtractor
- a route extractor
-
resolveLink
Description copied from class:RoutingLink
Resolves the link best matching the specified input.
The link is resolved by comparing the criteria coming from the routes to the criteria defined in the input.
- Specified by:
resolveLink
in classRoutingLink<A,
B, C extends PathRoute<A>, D extends PathRoute.Extractor<A, C, D>> - Parameters:
input
- an input- Returns:
- the matching link or null if no route matching the input was defined in the link
-
resolveAllLink
Description copied from class:RoutingLink
Resolves all links matching the specified input.
Links are resolved by comparing the criteria coming from the routes to the criteria defined in the input.
- Specified by:
resolveAllLink
in classRoutingLink<A,
B, C extends PathRoute<A>, D extends PathRoute.Extractor<A, C, D>> - Parameters:
input
- an input- Returns:
- a list of links sorted from the best matching to the least matching or an empty list if no route matching the input was defined in the link
-