diff --git a/docs/src/main/asciidoc/rest-json.adoc b/docs/src/main/asciidoc/rest-json.adoc index 805b216d6b0030..96472685692031 100644 --- a/docs/src/main/asciidoc/rest-json.adoc +++ b/docs/src/main/asciidoc/rest-json.adoc @@ -605,6 +605,26 @@ If set to `true` (default) then a *single instance* of a resource class is creat If set to `false` then a *new instance* of the resource class is created per each request. An explicit CDI scope annotation (`@RequestScoped`, `@ApplicationScoped`, etc.) always overrides the default behavior and specifies the lifecycle of resource instances. +== Include/Exclude JAX-RS classes with build time conditions + +Quarkus allows to include or exclude root resource, provider and feature classes directly thanks to build time conditions like it is possible with CDI beans. +Indeed, the different JAX-RS classes can be annotated with profile conditions (`@io.quarkus.arc.profile.IfBuildProfile` or `@io.quarkus.arc.profile.UnlessBuildProfile`) and/or with property conditions (`io.quarkus.arc.properties.IfBuildProperty` or `io.quarkus.arc.properties.UnlessBuildProperty`) to indicate to Quarkus at build time under which conditions the JAX-RS classes should be included. + +In the following example, Quarkus includes the endpoint `sayHello` if and only if the build profile `app1` has been enabled. + +[source,java] +---- +@IfBuildProfile("app1") +public class ResourceForApp1Only { + + @GET + @Path("sayHello") + public String sayHello() { + return "hello"; + } +} +---- + == Conclusion Creating JSON REST services with Quarkus is easy as it relies on proven and well known technologies. diff --git a/docs/src/main/asciidoc/resteasy-reactive.adoc b/docs/src/main/asciidoc/resteasy-reactive.adoc index f97e371568a582..6dfdb420ca0dc3 100644 --- a/docs/src/main/asciidoc/resteasy-reactive.adoc +++ b/docs/src/main/asciidoc/resteasy-reactive.adoc @@ -1790,3 +1790,23 @@ Or plain text: < < {"name":"roquefort"} ---- + +== Include/Exclude JAX-RS classes with build time conditions + +Quarkus allows to include or exclude root resource, provider and feature classes directly thanks to build time conditions like it is possible with CDI beans. +Indeed, the different JAX-RS classes can be annotated with profile conditions (`@io.quarkus.arc.profile.IfBuildProfile` or `@io.quarkus.arc.profile.UnlessBuildProfile`) and/or with property conditions (`io.quarkus.arc.properties.IfBuildProperty` or `io.quarkus.arc.properties.UnlessBuildProperty`) to indicate to Quarkus at build time under which conditions the JAX-RS classes should be included. + +In the following example, Quarkus includes the endpoint `sayHello` if and only if the build profile `app1` has been enabled. + +[source,java] +---- +@IfBuildProfile("app1") +public class ResourceForApp1Only { + + @GET + @Path("sayHello") + public String sayHello() { + return "hello"; + } +} +----