Skip to content

Commit c591a97

Browse files
committed
[UNDERTOW-2303] Further improvements to javadoc.
1 parent 6f6b824 commit c591a97

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

core/src/main/java/io/undertow/util/PathTemplateRouter.java

+21-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package io.undertow.util;
1919

20+
import io.undertow.server.HttpHandler;
21+
2022
/**
2123
* Routes requested URL paths to sets of underlying URL path templates.
2224
*
@@ -80,7 +82,7 @@
8082
* <li>It is assumed that most services that use routing based on path templates will setup a router once (when the service
8183
* starts) using a single thread and will then use that router to route millions of inbound requests using multiple concurrent
8284
* threads. Perhaps the setup will not happen exactly once, but the mutation of routes happen very few times when compared to
83-
* the number of times that requests are routed. For this reason this factory is heavily biased towards optimising the
85+
* the number of times that requests are routed. For this reason this design is heavily biased towards optimising the
8486
* performance of routing requests - sometimes at the expense of the performance of mutating routes.</li>
8587
* <li>Taking point (1) above into consideration. Documentation and comments refer to two distinct phases of processing:<ol>
8688
* <li>"Setup phase" as the phase/process during which routes are mutated and a router instance is created.</li>
@@ -98,19 +100,31 @@
98100
public interface PathTemplateRouter<T> {
99101

100102
/**
101-
* @return The default target for requests that do no match any specific routes.
103+
* @return The default target for requests that do not match any specific routes.
102104
*/
103105
T getDefaultTarget();
104106

105107
/**
106-
* Routes the requested URL path to the set of underlying URL path templates.
107-
*
108-
* @param path The requested URL path.
108+
* Routes the requested URL path to the best available target from the set of underlying URL path templates.
109109
*
110-
* @return The routing result. If the requested URL path matches any of the underlying URL path templates, then the most
110+
* <p>
111+
* If the requested URL path matches any of the underlying URL path templates, then the most
111112
* specific match (target and template) will be returned in the result. If the requested URL path does not match any of the
112-
* underlying URL path templates, then result will contain {@link #getDefaultTarget() } as the target and will contain an
113+
* underlying URL path templates, then the result will contain {@link #getDefaultTarget() } as the target and will contain an
113114
* empty Optional in {@link PathTemplateRouteResult#getPathTemplate() }.
115+
*
116+
* <p>
117+
* On completion of this method, the caller will have the best available target for the specified path. This method
118+
* merely provides the best target and does not call / action the target. That remains the responsibility of the caller.
119+
* This design allows the router to support different use cases, i.e.:
120+
* <ol>
121+
* <li>Determine the best available {@link HttpHandler} to process a client request based on the requested path.</li>
122+
* <li>Summarise HTTP access logs by normalising requested paths to available path templates.</li>
123+
* </ol>
124+
*
125+
* @param path The requested URL path.
126+
*
127+
* @return The routing result.
114128
*/
115129
PathTemplateRouteResult<T> route(String path);
116130
}

core/src/main/java/io/undertow/util/PathTemplateRouterFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ public S getTemplateTarget(final PathTemplateParser.PathTemplate<S> template) {
17671767
}
17681768

17691769
/**
1770-
* @return A mutable map of {@link PathTemplatePatternEqualsAdapter}s for all templates added to this builder.
1770+
* @return A mutable map of {@link PathTemplateParser.PathTemplatePatternEqualsAdapter}s for all templates added to this builder.
17711771
*/
17721772
public Map<PathTemplateParser.PathTemplatePatternEqualsAdapter<PathTemplateParser.PathTemplate<S>>, S> getTemplates() {
17731773
return templates;
@@ -1936,7 +1936,7 @@ public SimpleBuilder<T> defaultTarget(final T defaultTarget) {
19361936
}
19371937

19381938
/**
1939-
* @return A mutable map of {@link PathTemplatePatternEqualsAdapter}s for all templates added to this builder.
1939+
* @return A mutable map of {@link PathTemplateParser.PathTemplatePatternEqualsAdapter}s for all templates added to this builder.
19401940
*/
19411941
public Map<PathTemplateParser.PathTemplatePatternEqualsAdapter<PathTemplateParser.PathTemplate<Supplier<T>>>, Supplier<T>> getTemplates() {
19421942
return builder.getTemplates();

0 commit comments

Comments
 (0)