From 938d9e3d284837a7c42a3c78b844281ec5607ab1 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Mon, 2 Oct 2023 10:58:28 +0200 Subject: [PATCH] Review: mark->value, docs --- docs/src/main/asciidoc/http-reference.adoc | 18 +++++------ .../ResteasyStandaloneBuildStep.java | 4 +-- .../deployment/ResteasyReactiveProcessor.java | 4 +-- .../vertx/http/runtime/RouteConstants.java | 32 +++++++++---------- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/docs/src/main/asciidoc/http-reference.adoc b/docs/src/main/asciidoc/http-reference.adoc index 3bf94386d4fb0..642c75c9212b5 100644 --- a/docs/src/main/asciidoc/http-reference.adoc +++ b/docs/src/main/asciidoc/http-reference.adoc @@ -591,21 +591,19 @@ link:https://undertow.io/undertow-docs/undertow-docs-2.0.0/index.html#predicates If you are using a `web.xml` file as your configuration file, you can place it in the `src/main/resources/META-INF` directory. -== References +=== Built-in route order values -=== Well-known route order values +Route order values are the values that are specified via Vert.x route `io.vertx.ext.web.Route.order(int)` function. -Route order marks are the values that are specified via Vert.x route `io.vertx.ext.web.Route.order(int)` function. - -Quarkus uses a couple of route order marks itself. Your route order mark values should be at least a positive integer -value above `20000` (see `RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK`) to not interfere with the functionality provided -by Quarkus or its extensions. +Quarkus registers a couple of routes with specific order values. +The constants are defined in the `io.quarkus.vertx.http.runtime.RouteConstants` class and listed in the table below. +A custom route should define the order of value 20000 or higher so that it does not interfere with the functionality provided by Quarkus and extensions. Route order constants defined in `io.quarkus.vertx.http.runtime.RouteConstants` and known extensions: [cols="1,1,3"] |=== -| Route order mark| Constant name| Origin +| Route order value| Constant name| Origin | `Integer.MIN_VALUE` | `ROUTE_ORDER_ACCESS_LOG_HANDLER` | Access-log handler, if enabled in the configuration. | `Integer.MIN_VALUE` | `ROUTE_ORDER_RECORD_START_TIME` | Handler adding the start-time, if enabled in the configuration. | `Integer.MIN_VALUE` | `ROUTE_ORDER_HOT_REPLACEMENT` | -replacement body handler. @@ -615,7 +613,7 @@ Route order constants defined in `io.quarkus.vertx.http.runtime.RouteConstants` | `Integer.MIN_VALUE + 1` | `ROUTE_ORDER_BODY_HANDLER` | Body handler. | `-2` | `ROUTE_ORDER_UPLOAD_LIMIT` | Route that enforces the upload body size limit. | `0` | `ROUTE_ORDER_COMPRESSION` | Compression handler. -| `1000` | `ROUTE_ORDER_BEFORE_DEFAULT_MARK` | Route with priority over the default route (add an offset from this mark). +| `1000` | `ROUTE_ORDER_BEFORE_DEFAULT` | Route with priority over the default route (add an offset from this value). | `10000` | `ROUTE_ORDER_DEFAULT` | Default route order (i.e. Static Resources, Servlet). -| `20000` | `ROUTE_ORDER_AFTER_DEFAULT_MARK` | Route without priority over the default route (add an offset from this mark) +| `20000` | `ROUTE_ORDER_AFTER_DEFAULT` | Route without priority over the default route (add an offset from this value) |=== diff --git a/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java b/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java index 2709f4bf72292..6bcd316a4a08e 100644 --- a/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java +++ b/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java @@ -136,7 +136,7 @@ public void boot(ShutdownContextBuildItem shutdown, routes.produce( RouteBuildItem.builder() .orderedRoute(standalone.deploymentRootPath, - RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET) + RouteConstants.ROUTE_ORDER_AFTER_DEFAULT + REST_ROUTE_ORDER_OFFSET) .handler(handler).build()); String matchPath = standalone.deploymentRootPath; if (matchPath.endsWith("/")) { @@ -146,7 +146,7 @@ public void boot(ShutdownContextBuildItem shutdown, } // Match paths that begin with the deployment path routes.produce(RouteBuildItem.builder() - .orderedRoute(matchPath, RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET) + .orderedRoute(matchPath, RouteConstants.ROUTE_ORDER_AFTER_DEFAULT + REST_ROUTE_ORDER_OFFSET) .handler(handler).build()); recorder.start(shutdown, requireVirtual.isPresent()); diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java index 4091f71c4973d..2b018c4247b58 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java @@ -1251,11 +1251,11 @@ public void setupDeployment(BeanContainerBuildItem beanContainerBuildItem, .produce(new ResteasyReactiveDeploymentInfoBuildItem(deploymentInfo)); boolean servletPresent = false; - int order = RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET; + int order = RouteConstants.ROUTE_ORDER_AFTER_DEFAULT + REST_ROUTE_ORDER_OFFSET; if (capabilities.isPresent("io.quarkus.servlet")) { //if servlet is present we run RR before the default route //otherwise we run after it - order = RouteConstants.ROUTE_ORDER_BEFORE_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET; + order = RouteConstants.ROUTE_ORDER_BEFORE_DEFAULT + REST_ROUTE_ORDER_OFFSET; servletPresent = true; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/RouteConstants.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/RouteConstants.java index 2db9517ca55b8..6d00a3afa9b07 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/RouteConstants.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/RouteConstants.java @@ -1,7 +1,7 @@ package io.quarkus.vertx.http.runtime; /** - * Route order mark constants used in Quarkus, update {@code reactive-routes.adoc} when changing this class. + * Route order value constants used in Quarkus, update {@code reactive-routes.adoc} when changing this class. */ @SuppressWarnings("JavadocDeclaration") public final class RouteConstants { @@ -9,54 +9,54 @@ private RouteConstants() { } /** - * Order mark ({@value #ROUTE_ORDER_ACCESS_LOG_HANDLER}) for the access-log handler, if enabled in the configuration. + * Order value ({@value #ROUTE_ORDER_ACCESS_LOG_HANDLER}) for the access-log handler, if enabled in the configuration. */ public static final int ROUTE_ORDER_ACCESS_LOG_HANDLER = Integer.MIN_VALUE; /** - * Order mark ({@value #ROUTE_ORDER_RECORD_START_TIME}) for the handler adding the start-time, if enabled in the + * Order value ({@value #ROUTE_ORDER_RECORD_START_TIME}) for the handler adding the start-time, if enabled in the * configuration. */ public static final int ROUTE_ORDER_RECORD_START_TIME = Integer.MIN_VALUE; /** - * Order mark ({@value #ROUTE_ORDER_HOT_REPLACEMENT}) for the hot-replacement body handler. + * Order value ({@value #ROUTE_ORDER_HOT_REPLACEMENT}) for the hot-replacement body handler. */ public static final int ROUTE_ORDER_HOT_REPLACEMENT = Integer.MIN_VALUE; /** - * Order mark ({@value #ROUTE_ORDER_BODY_HANDLER_MANAGEMENT}) for the body handler for the management router. + * Order value ({@value #ROUTE_ORDER_BODY_HANDLER_MANAGEMENT}) for the body handler for the management router. */ public static final int ROUTE_ORDER_BODY_HANDLER_MANAGEMENT = Integer.MIN_VALUE; /** - * Order mark ({@value #ROUTE_ORDER_HEADERS}) for the handlers that add headers specified in the configuration. + * Order value ({@value #ROUTE_ORDER_HEADERS}) for the handlers that add headers specified in the configuration. */ public static final int ROUTE_ORDER_HEADERS = Integer.MIN_VALUE; /** - * Order mark ({@value #ROUTE_ORDER_CORS_MANAGEMENT}) for the CORS-Origin handler of the management router. + * Order value ({@value #ROUTE_ORDER_CORS_MANAGEMENT}) for the CORS-Origin handler of the management router. */ public static final int ROUTE_ORDER_CORS_MANAGEMENT = Integer.MIN_VALUE; /** - * Order mark ({@value #ROUTE_ORDER_BODY_HANDLER}) for the body handler. + * Order value ({@value #ROUTE_ORDER_BODY_HANDLER}) for the body handler. */ public static final int ROUTE_ORDER_BODY_HANDLER = Integer.MIN_VALUE + 1; /** - * Order mark ({@value #ROUTE_ORDER_UPLOAD_LIMIT}) for the route that enforces the upload body size limit. + * Order value ({@value #ROUTE_ORDER_UPLOAD_LIMIT}) for the route that enforces the upload body size limit. */ public static final int ROUTE_ORDER_UPLOAD_LIMIT = -2; /** - * Order mark ({@value #ROUTE_ORDER_COMPRESSION}) for the compression handler. + * Order value ({@value #ROUTE_ORDER_COMPRESSION}) for the compression handler. */ public static final int ROUTE_ORDER_COMPRESSION = 0; /** - * Order mark ({@value #ROUTE_ORDER_BEFORE_DEFAULT_MARK}) for route with priority over the default route (add an offset from - * this mark) + * Order value ({@value #ROUTE_ORDER_BEFORE_DEFAULT}) for route with priority over the default route (add an offset from + * this value) */ - public static final int ROUTE_ORDER_BEFORE_DEFAULT_MARK = 1_000; + public static final int ROUTE_ORDER_BEFORE_DEFAULT = 1_000; /** * Default route order (i.e. Static Resources, Servlet): ({@value #ROUTE_ORDER_DEFAULT}) */ public static final int ROUTE_ORDER_DEFAULT = 10_000; /** - * Order mark ({@value #ROUTE_ORDER_AFTER_DEFAULT_MARK}) for route without priority over the default route (add an offset - * from this mark) + * Order value ({@value #ROUTE_ORDER_AFTER_DEFAULT}) for route without priority over the default route (add an offset + * from this value) */ - public static final int ROUTE_ORDER_AFTER_DEFAULT_MARK = 20_000; + public static final int ROUTE_ORDER_AFTER_DEFAULT = 20_000; }