Skip to content

Commit

Permalink
Add a section in the doc of Resteasy and Resteasy reactive to describ…
Browse files Browse the repository at this point in the history
…e the feature
  • Loading branch information
essobedo committed Feb 22, 2021
1 parent 82ea1e0 commit 04bec49
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/src/main/asciidoc/rest-json.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 20 additions & 0 deletions docs/src/main/asciidoc/resteasy-reactive.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
----

0 comments on commit 04bec49

Please sign in to comment.