|
12 | 12 | import java.util.Arrays;
|
13 | 13 | import java.util.Collections;
|
14 | 14 | import java.util.Deque;
|
| 15 | +import java.util.Iterator; |
15 | 16 | import java.util.LinkedList;
|
16 | 17 | import java.util.List;
|
17 | 18 | import java.util.Map;
|
|
51 | 52 | import org.jboss.resteasy.reactive.server.SimpleResourceInfo;
|
52 | 53 | import org.jboss.resteasy.reactive.server.core.multipart.FormData;
|
53 | 54 | import org.jboss.resteasy.reactive.server.core.serialization.EntityWriter;
|
| 55 | +import org.jboss.resteasy.reactive.server.handlers.RestInitialHandler; |
54 | 56 | import org.jboss.resteasy.reactive.server.injection.ResteasyReactiveInjectionContext;
|
55 | 57 | import org.jboss.resteasy.reactive.server.jaxrs.AsyncResponseImpl;
|
56 | 58 | import org.jboss.resteasy.reactive.server.jaxrs.ContainerRequestContextImpl;
|
|
62 | 64 | import org.jboss.resteasy.reactive.server.jaxrs.SseEventSinkImpl;
|
63 | 65 | import org.jboss.resteasy.reactive.server.jaxrs.SseImpl;
|
64 | 66 | import org.jboss.resteasy.reactive.server.jaxrs.UriInfoImpl;
|
| 67 | +import org.jboss.resteasy.reactive.server.mapping.RequestMapper; |
65 | 68 | import org.jboss.resteasy.reactive.server.mapping.RuntimeResource;
|
66 | 69 | import org.jboss.resteasy.reactive.server.mapping.URITemplate;
|
67 | 70 | import org.jboss.resteasy.reactive.server.multipart.FormValue;
|
@@ -156,6 +159,8 @@ public abstract class ResteasyReactiveRequestContext
|
156 | 159 | private FormData formData;
|
157 | 160 | private boolean producesChecked;
|
158 | 161 |
|
| 162 | + private Iterator<RequestMapper.RequestMatch<RestInitialHandler.InitialMatch>> initialMatches; |
| 163 | + |
159 | 164 | public ResteasyReactiveRequestContext(Deployment deployment,
|
160 | 165 | ThreadSetupAction requestContext, ServerRestHandler[] handlerChain, ServerRestHandler[] abortHandlerChain) {
|
161 | 166 | super(handlerChain, abortHandlerChain, requestContext);
|
@@ -203,6 +208,30 @@ public void restart(RuntimeResource target, boolean setLocatorTarget) {
|
203 | 208 | this.target = target;
|
204 | 209 | }
|
205 | 210 |
|
| 211 | + /** |
| 212 | + * Restarts handler chain processing if another initial match exists. Initial matches are determined in RestInitialHandler. |
| 213 | + * |
| 214 | + * @return true if a restart occurred |
| 215 | + */ |
| 216 | + public boolean restartWithNextInitialMatch() { |
| 217 | + if (initialMatches == null || !initialMatches.hasNext()) { |
| 218 | + return false; |
| 219 | + } |
| 220 | + RequestMapper.RequestMatch<RestInitialHandler.InitialMatch> initialMatch = initialMatches |
| 221 | + .next(); |
| 222 | + restart(initialMatch.value.handlers); |
| 223 | + setMaxPathParams(initialMatch.value.maxPathParams); |
| 224 | + setRemaining(initialMatch.remaining); |
| 225 | + for (int i = 0; i < initialMatch.pathParamValues.length; ++i) { |
| 226 | + String pathParamValue = initialMatch.pathParamValues[i]; |
| 227 | + if (pathParamValue == null) { |
| 228 | + break; |
| 229 | + } |
| 230 | + setPathParamValue(i, initialMatch.pathParamValues[i]); |
| 231 | + } |
| 232 | + return true; |
| 233 | + } |
| 234 | + |
206 | 235 | /**
|
207 | 236 | * Meant to be used when an error occurred early in processing chain
|
208 | 237 | */
|
@@ -1254,6 +1283,14 @@ private String getResourceLocatorPathParam(String name, PreviousResource previou
|
1254 | 1283 |
|
1255 | 1284 | public abstract boolean resumeExternalProcessing();
|
1256 | 1285 |
|
| 1286 | + public Iterator<RequestMapper.RequestMatch<RestInitialHandler.InitialMatch>> getInitialMatches() { |
| 1287 | + return initialMatches; |
| 1288 | + } |
| 1289 | + |
| 1290 | + public void setInitialMatches(Iterator<RequestMapper.RequestMatch<RestInitialHandler.InitialMatch>> initialMatches) { |
| 1291 | + this.initialMatches = initialMatches; |
| 1292 | + } |
| 1293 | + |
1257 | 1294 | static class PreviousResource {
|
1258 | 1295 |
|
1259 | 1296 | private static final String PROPERTY_KEY = AbstractResteasyReactiveContext.CUSTOM_RR_PROPERTIES_PREFIX
|
|
0 commit comments