Skip to content

Commit 2ed8ef8

Browse files
committed
Sync documentation of main branch
1 parent 38ded0e commit 2ed8ef8

File tree

7 files changed

+249
-39
lines changed

7 files changed

+249
-39
lines changed

_generated-doc/main/config/quarkus-all-config.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19455,6 +19455,29 @@ endif::add-copy-button-to-env-var[]
1945519455
|string
1945619456
|
1945719457

19458+
a| [[quarkus-hibernate-orm_quarkus-hibernate-orm-database-version-check-enabled]] [.property-path]##link:#quarkus-hibernate-orm_quarkus-hibernate-orm-database-version-check-enabled[`quarkus.hibernate-orm.database.version-check.enabled`]##
19459+
19460+
`quarkus.hibernate-orm."persistence-unit-name".database.version-check.enabled`
19461+
19462+
[.description]
19463+
--
19464+
Whether Hibernate ORM should check on startup
19465+
that the version of the database matches the version configured on the dialect
19466+
(either the default version, or the one set through `quarkus.datasource.db-version`).
19467+
19468+
This should be set to `false` if the database is not available on startup.
19469+
19470+
19471+
ifdef::add-copy-button-to-env-var[]
19472+
Environment variable: env_var_with_copy_button:+++QUARKUS_HIBERNATE_ORM_DATABASE_VERSION_CHECK_ENABLED+++[]
19473+
endif::add-copy-button-to-env-var[]
19474+
ifndef::add-copy-button-to-env-var[]
19475+
Environment variable: `+++QUARKUS_HIBERNATE_ORM_DATABASE_VERSION_CHECK_ENABLED+++`
19476+
endif::add-copy-button-to-env-var[]
19477+
--
19478+
|boolean
19479+
|``true` if the dialect was set automatically by Quarkus, `false` if it was set explicitly`
19480+
1945819481

1945919482
h|[[quarkus-hibernate-orm_section_quarkus-hibernate-orm-dialect]] [.section-name.section-level0]##link:#quarkus-hibernate-orm_section_quarkus-hibernate-orm-dialect[Dialect related configuration]##
1946019483
h|Type

_generated-doc/main/config/quarkus-hibernate-orm.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,29 @@ endif::add-copy-button-to-env-var[]
595595
|string
596596
|
597597

598+
a| [[quarkus-hibernate-orm_quarkus-hibernate-orm-database-version-check-enabled]] [.property-path]##link:#quarkus-hibernate-orm_quarkus-hibernate-orm-database-version-check-enabled[`quarkus.hibernate-orm.database.version-check.enabled`]##
599+
600+
`quarkus.hibernate-orm."persistence-unit-name".database.version-check.enabled`
601+
602+
[.description]
603+
--
604+
Whether Hibernate ORM should check on startup
605+
that the version of the database matches the version configured on the dialect
606+
(either the default version, or the one set through `quarkus.datasource.db-version`).
607+
608+
This should be set to `false` if the database is not available on startup.
609+
610+
611+
ifdef::add-copy-button-to-env-var[]
612+
Environment variable: env_var_with_copy_button:+++QUARKUS_HIBERNATE_ORM_DATABASE_VERSION_CHECK_ENABLED+++[]
613+
endif::add-copy-button-to-env-var[]
614+
ifndef::add-copy-button-to-env-var[]
615+
Environment variable: `+++QUARKUS_HIBERNATE_ORM_DATABASE_VERSION_CHECK_ENABLED+++`
616+
endif::add-copy-button-to-env-var[]
617+
--
618+
|boolean
619+
|``true` if the dialect was set automatically by Quarkus, `false` if it was set explicitly`
620+
598621

599622
h|[[quarkus-hibernate-orm_section_quarkus-hibernate-orm-dialect]] [.section-name.section-level0]##link:#quarkus-hibernate-orm_section_quarkus-hibernate-orm-dialect[Dialect related configuration]##
600623
h|Type

_generated-doc/main/config/quarkus-hibernate-orm_quarkus.hibernate-orm.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,29 @@ endif::add-copy-button-to-env-var[]
595595
|string
596596
|
597597

598+
a| [[quarkus-hibernate-orm_quarkus-hibernate-orm-database-version-check-enabled]] [.property-path]##link:#quarkus-hibernate-orm_quarkus-hibernate-orm-database-version-check-enabled[`quarkus.hibernate-orm.database.version-check.enabled`]##
599+
600+
`quarkus.hibernate-orm."persistence-unit-name".database.version-check.enabled`
601+
602+
[.description]
603+
--
604+
Whether Hibernate ORM should check on startup
605+
that the version of the database matches the version configured on the dialect
606+
(either the default version, or the one set through `quarkus.datasource.db-version`).
607+
608+
This should be set to `false` if the database is not available on startup.
609+
610+
611+
ifdef::add-copy-button-to-env-var[]
612+
Environment variable: env_var_with_copy_button:+++QUARKUS_HIBERNATE_ORM_DATABASE_VERSION_CHECK_ENABLED+++[]
613+
endif::add-copy-button-to-env-var[]
614+
ifndef::add-copy-button-to-env-var[]
615+
Environment variable: `+++QUARKUS_HIBERNATE_ORM_DATABASE_VERSION_CHECK_ENABLED+++`
616+
endif::add-copy-button-to-env-var[]
617+
--
618+
|boolean
619+
|``true` if the dialect was set automatically by Quarkus, `false` if it was set explicitly`
620+
598621

599622
h|[[quarkus-hibernate-orm_section_quarkus-hibernate-orm-dialect]] [.section-name.section-level0]##link:#quarkus-hibernate-orm_section_quarkus-hibernate-orm-dialect[Dialect related configuration]##
600623
h|Type

_versions/main/guides/cdi-integration.adoc

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,73 @@ public class TestRecorder {
419419
----
420420
<1> Pass a contextual reference of `Bar` to the constructor of `Foo`.
421421

422+
=== Inactive Synthetic Beans
423+
424+
In the case when one needs to register multiple synthetic beans at build time but only wants a subset of them active at runtime, it is useful to be able to mark a synthetic bean as _inactive_.
425+
This is done by configuring a "check active" procedure, which should be a `Supplier<ActiveResult>` obtained from a recorder:
426+
427+
.Inactive Synthetic Bean - Build Step Example
428+
[source,java]
429+
----
430+
@BuildStep
431+
@Record(RUNTIME_INIT)
432+
SyntheticBeanBuildItem syntheticBean(TestRecorder recorder) {
433+
return SyntheticBeanBuildItem.configure(Foo.class)
434+
.scope(Singleton.class)
435+
.startup() // <1>
436+
.checkActive(recorder.isFooActive()) // <2>
437+
.createWith(recorder.createFoo())
438+
.done();
439+
}
440+
----
441+
<1> A bean that might be inactive is typically initialized eagerly, to make sure that an error is thrown at application startup.
442+
If the bean is in fact inactive, but is not injected into an always-active bean, eager initialization is skipped and no error is thrown.
443+
<2> Configures the "check active" procedure.
444+
445+
.Inactive Synthetic Bean - Recorder Example
446+
[source,java]
447+
----
448+
@Recorder
449+
public class TestRecorder {
450+
public Supplier<ActiveResult> isFooActive() {
451+
return () -> {
452+
if (... should not be active ...) { // <1>
453+
return ActiveResult.inactive("explanation"); // <2>
454+
}
455+
return ActiveResult.active();
456+
};
457+
}
458+
459+
public Function<SyntheticCreationalContext<Foo>, Foo> createFoo() {
460+
return (context) -> {
461+
return new Foo();
462+
};
463+
}
464+
}
465+
----
466+
<1> The condition when the synthetic bean should be inactive.
467+
<2> Proper explanation of why the bean is inactive.
468+
Another inactive `ActiveResult` may also be provided as a cause, if this bean's inactivity stems from another bean's inactivity.
469+
470+
If an inactive bean is injected somewhere, or is dynamically looked up, an `InactiveBeanException` is thrown.
471+
The error message contains the reason (from the `ActiveResult`), the cause chain (also from the `ActiveResult`), and possibly also a list of all injection points that resolve to this bean.
472+
473+
If you want to handle the inactive case gracefully, you should always inject possibly inactive beans using `Instance<>`.
474+
You also need to check before obtaining the actual instance:
475+
476+
[source,java]
477+
----
478+
import io.quarkus.arc.InjectableInstance;
479+
480+
@Inject
481+
InjectableInstance<Foo> foo;
482+
483+
if (foo.getHandle().getBean().isActive()) {
484+
Foo foo = foo.get();
485+
...
486+
}
487+
----
488+
422489
[[synthetic_observers]]
423490
== Use Case - Synthetic Observers
424491

_versions/main/guides/hibernate-orm.adoc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,20 @@ or implicitly set by the Quarkus build process to a minimum supported version of
205205
Quarkus will try to check this preconfigured version against the actual database version on startup,
206206
leading to a startup failure when the actual version is lower.
207207
208-
This is because Hibernate ORM may generate SQL that is invalid
209-
for versions of the database older than what is configured,
210-
which would lead to runtime exceptions.
208+
This is a safeguard: for versions of the database older than what is configured,
209+
Hibernate ORM may generate SQL that is invalid which would lead to runtime exceptions.
211210
211+
// TODO disable the check by default when offline startup is opted in
212+
// See https://github.com/quarkusio/quarkus/issues/13522
212213
If the database cannot be reached, a warning will be logged but startup will proceed.
214+
You can optionally disable the version check if you know the database won't be reachable on startup
215+
using <<quarkus-hibernate-orm_quarkus-hibernate-orm-database-version-check-enabled,`quarkus.hibernate-orm.database.version-check.enabled=false`>>.
216+
217+
// TODO change the default to "always enabled" when we solve version detection problems
218+
// See https://github.com/quarkusio/quarkus/issues/43703
219+
// See https://github.com/quarkusio/quarkus/issues/42255
220+
The version check is disabled by default when a dialect is set explicitly,
221+
as a workaround for https://github.com/quarkusio/quarkus/issues/42255[#42255]/link:https://github.com/quarkusio/quarkus/issues/43703[#43703].
213222
====
214223

215224
[[hibernate-dialect-other-databases]]

_versions/main/guides/qute-reference.adoc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,15 +1710,31 @@ A CDI bean annotated with `@Named` can be referenced in any template through `cd
17101710
NOTE: `@Named @Dependent` beans are shared across all expressions in a template for a single rendering operation, and destroyed after the rendering finished.
17111711

17121712
All expressions with `cdi` and `inject` namespaces are validated during build.
1713-
17141713
For the expression `cdi:personService.findPerson(10).name`, the implementation class of the injected bean must either declare the `findPerson` method or a matching <<template_extension_methods,template extension method>> must exist.
1715-
17161714
For the expression `inject:foo.price`, the implementation class of the injected bean must either have the `price` property (e.g. a `getPrice()` method) or a matching <<template_extension_methods,template extension method>> must exist.
17171715

17181716
NOTE: A `ValueResolver` is also generated for all beans annotated with `@Named` so that it's possible to access its properties without reflection.
17191717

17201718
TIP: If your application serves xref:http-reference.adoc[HTTP requests] you can also inject the current `io.vertx.core.http.HttpServerRequest` via the `inject` namespace, e.g. `{inject:vertxRequest.getParam('foo')}`.
17211719

1720+
Sometimes it may be necessary to access public methods and properties of a CDI bean that is not annotated with `@Named`.
1721+
However, if you don't control the source of the bean it is not possible to add the `@Named` annotation.
1722+
Nevertheless, it is possible to create an intermediate CDI bean annotated with `@Named`.
1723+
This intermediate bean can inject the bean in question and make it accessible.
1724+
A Java record is a very convenient way to define such an intermediate CDI bean.
1725+
1726+
[source,java]
1727+
----
1728+
@Named <1> <2>
1729+
public record UserData(UserInfo info, @LoggedIn String username) { <3>
1730+
}
1731+
----
1732+
<1> If no name is explicitly specified by the `value` member the https://jakarta.ee/specifications/cdi/4.1/jakarta-cdi-spec-4.1#default_name[default name is assigned] - the simple name of the bean class, after converting the first character to lower case. In this particular case, the default name is `userData`.
1733+
<2> The `@Singleton` scope is added automatically.
1734+
<3> All parameters of the canonical constructor are injection points. The accessor methods can be used to obtain the injected bean.
1735+
1736+
And then in a template you can simply use `{cdi:userData.info}` or `{cdi:userData.username}`.
1737+
17221738
[[typesafe_expressions]]
17231739
=== Type-safe Expressions
17241740

_versions/main/guides/rest-client.adoc

Lines changed: 83 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,89 @@ Furthermore, the client can also send arbitrarily large files if one of the foll
337337
* `File`
338338
* `Path`
339339

340+
=== Getting other response properties
341+
342+
==== Using RestResponse
343+
344+
If you need to get more properties of the HTTP response than just the body, such as the status code
345+
or headers, you can make your method return `org.jboss.resteasy.reactive.RestResponse` from a method.
346+
An example of this could look like:
347+
348+
[source,java]
349+
----
350+
package org.acme.rest.client;
351+
352+
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
353+
354+
import jakarta.ws.rs.GET;
355+
import jakarta.ws.rs.Path;
356+
import org.jboss.resteasy.reactive.RestQuery;
357+
import org.jboss.resteasy.reactive.RestResponse;
358+
359+
import java.util.Set;
360+
361+
@Path("/extensions")
362+
@RegisterRestClient
363+
public interface ExtensionsService {
364+
365+
@GET
366+
RestResponse<Set<Extension>> getByIdResponseProperties(@RestQuery String id);
367+
}
368+
----
369+
370+
NOTE: You can also use the Jakarta REST type link:{jaxrsapi}/jakarta/ws/rs/core/Response.html[`Response`] but it is
371+
not strongly typed to your entity.
372+
373+
== Create the Jakarta REST resource
374+
375+
Create the `src/main/java/org/acme/rest/client/ExtensionsResource.java` file with the following content:
376+
377+
378+
[source,java]
379+
----
380+
package org.acme.rest.client;
381+
382+
import org.eclipse.microprofile.rest.client.inject.RestClient;
383+
384+
import jakarta.ws.rs.GET;
385+
import jakarta.ws.rs.Path;
386+
import java.util.Set;
387+
388+
@Path("/extension")
389+
public class ExtensionsResource {
390+
391+
@RestClient // <1>
392+
ExtensionsService extensionsService;
393+
394+
395+
@GET
396+
@Path("/id/{id}")
397+
public Set<Extension> id(String id) {
398+
return extensionsService.getById(id);
399+
}
400+
401+
@GET
402+
@Path("/properties")
403+
public RestResponse<Set<Extension>> responseProperties(@RestQuery String id) {
404+
RestResponse<Set<Extension>> clientResponse = extensionsService.getByIdResponseProperties(id); //<2>
405+
String contentType = clientResponse.getHeaderString("Content-Type");
406+
int status = clientResponse.getStatus();
407+
String setCookie = clientResponse.getHeaderString("Set-Cookie");
408+
Date lastModified = clientResponse.getLastModified();
409+
410+
Log.infof("content-Type: %s status: %s Last-Modified: %s Set-Cookie: %s", contentType, status, lastModified,
411+
setCookie);
412+
413+
return RestResponse.fromResponse(clientResponse);
414+
}
415+
}
416+
----
417+
418+
There are two interesting parts in this listing:
419+
420+
<1> the client stub is injected with the `@RestClient` annotation instead of the usual CDI `@Inject`
421+
<2> `org.jboss.resteasy.reactive.RestResponse` used as effective way of getting response properties via RestResponse directly from RestClient,
422+
as described in <<Using RestResponse>>
340423

341424
== Create the configuration
342425

@@ -411,40 +494,6 @@ quarkus.rest-client.alpn=true
411494
quarkus.rest-client.extensions-api.alpn=true
412495
----
413496

414-
== Create the Jakarta REST resource
415-
416-
Create the `src/main/java/org/acme/rest/client/ExtensionsResource.java` file with the following content:
417-
418-
419-
[source,java]
420-
----
421-
package org.acme.rest.client;
422-
423-
import org.eclipse.microprofile.rest.client.inject.RestClient;
424-
425-
import jakarta.ws.rs.GET;
426-
import jakarta.ws.rs.Path;
427-
import java.util.Set;
428-
429-
@Path("/extension")
430-
public class ExtensionsResource {
431-
432-
@RestClient // <1>
433-
ExtensionsService extensionsService;
434-
435-
436-
@GET
437-
@Path("/id/{id}")
438-
public Set<Extension> id(String id) {
439-
return extensionsService.getById(id);
440-
}
441-
}
442-
----
443-
444-
There are two interesting parts in this listing:
445-
446-
<1> the client stub is injected with the `@RestClient` annotation instead of the usual CDI `@Inject`
447-
448497
== Programmatic client creation with QuarkusRestClientBuilder
449498

450499
Instead of annotating the client with `@RegisterRestClient`, and injecting

0 commit comments

Comments
 (0)