From 7faec0b80135e77633db848fa0ac6644af10d97b Mon Sep 17 00:00:00 2001 From: tvallin Date: Tue, 27 Feb 2024 18:47:09 +0100 Subject: [PATCH 1/4] update documentation Signed-off-by: tvallin --- docs/src/main/asciidoc/mp/server.adoc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/mp/server.adoc b/docs/src/main/asciidoc/mp/server.adoc index dfe5087ad86..3bbbeece00e 100644 --- a/docs/src/main/asciidoc/mp/server.adoc +++ b/docs/src/main/asciidoc/mp/server.adoc @@ -300,7 +300,7 @@ You can configure `@RoutingPath` to define the path a service is registered on. ===== Configuration override of routing path For each HTTP service class you can define the routing path by specifying a configuration -option `class-name.routing-path.path`. +option `class-name.routing-path.path`. The `routing-path` configuration can be applied to Jax-RS application. Example (YAML) configuration for a class `io.helidon.example.AdminService` that changes the routing path to `/management`: @@ -312,6 +312,20 @@ io.helidon.examples.AdminService: path: "/management" ---- +The same example configuration for `.properties` file: + +[source,properties] +---- +io.helidon.examples.AdminService.routing-path.path=/management +---- + +Use the following configuration key prefix if there is no explicit Jax-RS `jakarta.ws.rs.Application`: + +[source,properties] +---- +jakarta.ws.rs.core.Application.routing-path.path=/management +---- + === Serving Static Content [source,properties] From 0868f60d23c0680cf41315e8c0239357e1ac1353 Mon Sep 17 00:00:00 2001 From: tvallin Date: Wed, 28 Feb 2024 11:52:04 +0100 Subject: [PATCH 2/4] review changes Signed-off-by: tvallin --- .../asciidoc/mp/jaxrs/jaxrs-applications.adoc | 41 ++++++++++++++++++- docs/src/main/asciidoc/mp/server.adoc | 15 +------ .../mp/jaxrs/JaxrsApplicationsSnippets.java | 7 ++++ 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc index 91037e38ff3..215b6ab9c52 100644 --- a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc +++ b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc @@ -64,7 +64,46 @@ in each subclass using the collections in steps (2) and (3) only as defaults, i. both return empty sets. NOTE: Helidon treats `@Path` and `@Provided` as bean-defining annotations but, as stated above, -`Application` subclasses may require additional annotations depending on the discovery mode. +`Application` subclasses may require additional annotations depending on the discovery mode + +== Setting Application Path + +The application path, also known as context path, is the base URI used to serve all resource URIs provided +by `@Path` annotation. This section describe how to set it with annotation or configuration files. + +When an `Application` subclass is provided, use the `@ApplicationPath`: + +[source,java] +---- +include::{sourcedir}/mp/jaxrs/JaxrsApplicationsSnippets.java[tag=snippet_2, indent=0] +---- + +The served resources can be reached through `/myApplication/{myResources}` endpoint. It can be overridden +by configuration file. + +Example of custom application path using `.yaml` file: + +[source,yaml] +---- +io.helidon.examples.MyApplication: + routing-path: + path: "/myApplication" +---- + +The same configuration works for `.properties` file: + +[source,properties] +---- +io.helidon.examples.MyApplication.routing-path.path=/myApplication +---- + +If no `Application` is not provided, a _synthetic_ subclass is created and can be configured using +this property: + +[source,properties] +---- +jakarta.ws.rs.core.Application.routing-path.path=/myApplication +---- == Access to Application Instances diff --git a/docs/src/main/asciidoc/mp/server.adoc b/docs/src/main/asciidoc/mp/server.adoc index 3bbbeece00e..4951dbc3513 100644 --- a/docs/src/main/asciidoc/mp/server.adoc +++ b/docs/src/main/asciidoc/mp/server.adoc @@ -301,6 +301,7 @@ You can configure `@RoutingPath` to define the path a service is registered on. For each HTTP service class you can define the routing path by specifying a configuration option `class-name.routing-path.path`. The `routing-path` configuration can be applied to Jax-RS application. +See xref:jaxrs/jaxrs-applications.adoc[Jakarta REST Application] for more information. Example (YAML) configuration for a class `io.helidon.example.AdminService` that changes the routing path to `/management`: @@ -312,20 +313,6 @@ io.helidon.examples.AdminService: path: "/management" ---- -The same example configuration for `.properties` file: - -[source,properties] ----- -io.helidon.examples.AdminService.routing-path.path=/management ----- - -Use the following configuration key prefix if there is no explicit Jax-RS `jakarta.ws.rs.Application`: - -[source,properties] ----- -jakarta.ws.rs.core.Application.routing-path.path=/management ----- - === Serving Static Content [source,properties] diff --git a/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java b/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java index e60c4a7391a..9d7123c41b7 100644 --- a/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java +++ b/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java @@ -17,6 +17,7 @@ import io.helidon.webserver.http.ServerRequest; +import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.core.Application; @@ -36,4 +37,10 @@ public void get(@Context ServerRequest serverRequest) { } // end::snippet_1[] + // tag::snippet_2[] + @ApplicationPath("/myApplication") + public class MyApplication extends Application { + + } + // end::snippet_2[] } From ed8f00f2f5f47f4aeb5cbba6acc233d10c27df13 Mon Sep 17 00:00:00 2001 From: tvallin Date: Thu, 29 Feb 2024 11:51:09 +0100 Subject: [PATCH 3/4] additional review changes Signed-off-by: tvallin --- .../src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc | 10 +++++----- .../docs/mp/jaxrs/JaxrsApplicationsSnippets.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc index 215b6ab9c52..0c214bd2323 100644 --- a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc +++ b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc @@ -68,7 +68,7 @@ NOTE: Helidon treats `@Path` and `@Provided` as bean-defining annotations but, a == Setting Application Path -The application path, also known as context path, is the base URI used to serve all resource URIs provided +The application path, also known as context root, is the base URI used to serve all resource URIs provided by `@Path` annotation. This section describe how to set it with annotation or configuration files. When an `Application` subclass is provided, use the `@ApplicationPath`: @@ -78,7 +78,7 @@ When an `Application` subclass is provided, use the `@ApplicationPath`: include::{sourcedir}/mp/jaxrs/JaxrsApplicationsSnippets.java[tag=snippet_2, indent=0] ---- -The served resources can be reached through `/myApplication/{myResources}` endpoint. It can be overridden +The served resources can be reached through `/my-application/{myResources}` endpoint. It can be overridden by configuration file. Example of custom application path using `.yaml` file: @@ -87,14 +87,14 @@ Example of custom application path using `.yaml` file: ---- io.helidon.examples.MyApplication: routing-path: - path: "/myApplication" + path: "/my-application" ---- The same configuration works for `.properties` file: [source,properties] ---- -io.helidon.examples.MyApplication.routing-path.path=/myApplication +io.helidon.examples.MyApplication.routing-path.path=/my-application ---- If no `Application` is not provided, a _synthetic_ subclass is created and can be configured using @@ -102,7 +102,7 @@ this property: [source,properties] ---- -jakarta.ws.rs.core.Application.routing-path.path=/myApplication +jakarta.ws.rs.core.Application.routing-path.path=/my-application ---- == Access to Application Instances diff --git a/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java b/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java index 9d7123c41b7..0f16275afee 100644 --- a/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java +++ b/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java @@ -38,7 +38,7 @@ public void get(@Context ServerRequest serverRequest) { // end::snippet_1[] // tag::snippet_2[] - @ApplicationPath("/myApplication") + @ApplicationPath("/my-application") public class MyApplication extends Application { } From 9e91743cb4b6c46a7d6ec9208582ea24305c2977 Mon Sep 17 00:00:00 2001 From: tvallin Date: Thu, 29 Feb 2024 18:06:34 +0100 Subject: [PATCH 4/4] review changes Signed-off-by: tvallin --- docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc index 0c214bd2323..c4d3d9fae2d 100644 --- a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc +++ b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc @@ -69,7 +69,7 @@ NOTE: Helidon treats `@Path` and `@Provided` as bean-defining annotations but, a == Setting Application Path The application path, also known as context root, is the base URI used to serve all resource URIs provided -by `@Path` annotation. This section describe how to set it with annotation or configuration files. +by `@Path` annotation. This section describes how to set it with an annotation or configuration file. When an `Application` subclass is provided, use the `@ApplicationPath`: @@ -97,7 +97,7 @@ The same configuration works for `.properties` file: io.helidon.examples.MyApplication.routing-path.path=/my-application ---- -If no `Application` is not provided, a _synthetic_ subclass is created and can be configured using +If an `Application` is not provided, a _synthetic_ subclass is created and can be configured using this property: [source,properties]