Class OutboundAcceptContentRoutingLink<A,B,C extends AcceptContentRoute<A>,D extends AcceptContentRoute.Extractor<A,C,D>>
- Type Parameters:
A- the resource typeB- the input typeC- the outbound accept content route typeD- the outbound accept content route extractor type
A RoutingLink implementation resolving resources by matching the accepted content types in an input.
When considering an HTTP server, it allows to select the resource (e.g. handler) that best match the content types accepted in the request.
- 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
ConstructorsConstructorDescriptionOutboundAcceptContentRoutingLink(boolean strict) Creates a terminal outbound accept content routing link.OutboundAcceptContentRoutingLink(Supplier<RoutingLink<A, B, C, D>> nextLinkFactory) Creates a strict outbound accept content routing link in a routing chain.OutboundAcceptContentRoutingLink(Supplier<RoutingLink<A, B, C, D>> nextLinkFactory, boolean strict) Creates an outbound accept content routing link in a routing chain. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanDetermines whether the link can link the specified route.protected voidextractLinks(D routeExtractor) Populates the specified route extractor with the criteria managed by the link.protected abstract List<Headers.Accept> getAllAcceptHeaders(B input) Extracts all accepted content types from the specified 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 voidRefreshes enabled links.protected voidremoveLink(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
-
OutboundAcceptContentRoutingLink
public OutboundAcceptContentRoutingLink() -
OutboundAcceptContentRoutingLink
public OutboundAcceptContentRoutingLink(boolean strict) Creates a terminal outbound accept content routing link.
- Parameters:
strict- true to throw aNotAcceptableExceptionwhen no match is found, false otherwise
-
OutboundAcceptContentRoutingLink
Creates a strict outbound accept content routing link in a routing chain.
- Parameters:
nextLinkFactory- the next routing link factory
-
OutboundAcceptContentRoutingLink
public OutboundAcceptContentRoutingLink(Supplier<RoutingLink<A, B, C, D>> nextLinkFactory, boolean strict) Creates an outbound accept content routing link in a routing chain.
- Parameters:
nextLinkFactory- the next routing link factorystrict- true to throw aNotAcceptableExceptionwhen no match is found, false otherwise
-
-
Method Details
-
getAllAcceptHeaders
Extracts all accepted content types from the specified input.
- Parameters:
input- an input- Returns:
- a list of accepted content types or an empty list
-
canLink
Description copied from class:RoutingLinkDetermines 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:
canLinkin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.Extractor<A, C, D>> - Parameters:
route- a route- Returns:
- true if the link can
-
getLink
Description copied from class:RoutingLinkReturns the next link in the routing chain that is matching the specified route.
- Specified by:
getLinkin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.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:RoutingLinkReturns 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:
getOrSetLinkin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.Extractor<A, C, D>> - Parameters:
route- a route- Returns:
- the next routing link in the routing chain
-
getLinks
Description copied from class:RoutingLinkReturns all links bound to the link.
- Specified by:
getLinksin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.Extractor<A, C, D>> - Returns:
- the list of links bound to the link
-
removeLink
Description copied from class:RoutingLinkRemoves the link matching the specified route.
- Specified by:
removeLinkin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.Extractor<A, C, D>> - Parameters:
route- a route
-
refreshEnabled
protected void refreshEnabled()Description copied from class:RoutingLinkRefreshes 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:
refreshEnabledin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.Extractor<A, C, D>>
-
extractLinks
Description copied from class:RoutingLinkPopulates 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:
extractLinksin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.Extractor<A, C, D>> - Parameters:
routeExtractor- a route extractor
-
resolveLink
Description copied from class:RoutingLinkResolves 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:
resolveLinkin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.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:RoutingLinkResolves 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:
resolveAllLinkin classRoutingLink<A,B, C extends AcceptContentRoute<A>, D extends AcceptContentRoute.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
-