Class ContentRoutingLink<A,B,C extends ContentRoute<A>,D extends ContentRoute.Extractor<A,C,D>>
- Type Parameters:
A
- the resource typeB
- the input typeC
- the content route typeD
- the content route extractor type
A RoutingLink
implementation resolving resources by matching the content type 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 content routing link.ContentRoutingLink
(Supplier<RoutingLink<A, B, C, D>> nextLinkFactory) Creates a content 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 abstract Headers.ContentType
getContentTypeHeader
(B input) Extracts the content type from the input.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 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.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
-
ContentRoutingLink
public ContentRoutingLink()Creates a terminal content routing link.
-
ContentRoutingLink
Creates a content routing link in a routing chain.
- Parameters:
nextLinkFactory
- the next routing link factory
-
-
Method Details
-
getContentTypeHeader
Extracts the content type from the input.
- Parameters:
input
- an input- Returns:
- a content type
-
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...).
- Specified by:
canLink
in classRoutingLink<A,
B, C extends ContentRoute<A>, D extends ContentRoute.Extractor<A, C, D>> - Parameters:
route
- a route- Returns:
- true if the link can
-
getLink
Description copied from class:RoutingLink
Returns the next link in the routing chain that is matching the specified route.
- Specified by:
getLink
in classRoutingLink<A,
B, C extends ContentRoute<A>, D extends ContentRoute.Extractor<A, C, D>> - Parameters:
route
- a route- Returns:
- the next routing link in the routing chain or null if there is no link matching the 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 ContentRoute<A>, D extends ContentRoute.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.
- Specified by:
getLinks
in classRoutingLink<A,
B, C extends ContentRoute<A>, D extends ContentRoute.Extractor<A, C, D>> - Returns:
- the list of 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 ContentRoute<A>, D extends ContentRoute.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 ContentRoute<A>, D extends ContentRoute.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 ContentRoute<A>, D extends ContentRoute.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 ContentRoute<A>, D extends ContentRoute.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 ContentRoute<A>, D extends ContentRoute.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
-