Class PathRoutingLink<A,B,C extends PathRoute<A>,D extends PathRoute.Extractor<A,C,D>>

java.lang.Object
io.inverno.mod.http.base.router.RoutingLink<A,B,C,D>
io.inverno.mod.http.base.router.link.PathRoutingLink<A,B,C,D>
Type Parameters:
A - the resource type
B - the input type
C - the path route type
D - the path route extractor type

public abstract class PathRoutingLink<A,B,C extends PathRoute<A>,D extends PathRoute.Extractor<A,C,D>> extends RoutingLink<A,B,C,D>

A RoutingLink implementation resolving resources by matching the path in an input.

Since:
1.12
Author:
Jeremy Kuhn
See Also:
  • Constructor Details

    • PathRoutingLink

      public PathRoutingLink()

      Creates a terminal path routing link.

    • PathRoutingLink

      public PathRoutingLink(Supplier<RoutingLink<A,B,C,D>> nextLinkFactory)

      Creates a path routing link in a routing chain.

      Parameters:
      nextLinkFactory - the next routing link factory
  • Method Details

    • getNormalizedPath

      protected abstract String getNormalizedPath(B input)

      Extracts the absolute normalized path from the input.

      Parameters:
      input - an input
      Returns:
      an absolute normalized path
    • setPathParameters

      protected abstract void setPathParameters(B input, Map<String,String> parameters)

      Injects the parameters extracted when matching the path using a path pattern in the input.

      Parameters:
      input - an input
      parameters - the extracted parameters
    • canLink

      protected boolean canLink(C route)
      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 class RoutingLink<A,B,C extends PathRoute<A>,D extends PathRoute.Extractor<A,C,D>>
      Parameters:
      route - a route
      Returns:
      true if the link can
    • getLink

      protected RoutingLink<A,B,C,D> getLink(C route)
      Description copied from class: RoutingLink

      Returns the next link in the routing chain that is matching the specified route.

      Specified by:
      getLink in class RoutingLink<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 or null if there is no link matching the route
    • getOrSetLink

      protected RoutingLink<A,B,C,D> getOrSetLink(C route)
      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 class RoutingLink<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

      protected Collection<RoutingLink<A,B,C,D>> getLinks()
      Description copied from class: RoutingLink

      Returns all links bound to the link.

      Specified by:
      getLinks in class RoutingLink<A,B,C extends PathRoute<A>,D extends PathRoute.Extractor<A,C,D>>
      Returns:
      the list of links bound to the link
    • removeLink

      protected void removeLink(C route)
      Description copied from class: RoutingLink

      Removes the link matching the specified route.

      Specified by:
      removeLink in class RoutingLink<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 class RoutingLink<A,B,C extends PathRoute<A>,D extends PathRoute.Extractor<A,C,D>>
    • extractLinks

      protected void extractLinks(D routeExtractor)
      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 class RoutingLink<A,B,C extends PathRoute<A>,D extends PathRoute.Extractor<A,C,D>>
      Parameters:
      routeExtractor - a route extractor
    • resolveLink

      protected RoutingLink<A,B,C,D> resolveLink(B input)
      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 class RoutingLink<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

      protected List<RoutingLink<A,B,C,D>> resolveAllLink(B input)
      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 class RoutingLink<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