You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|``true` if the dialect was set automatically by Quarkus, `false` if it was set explicitly`
19480
+
19458
19481
19459
19482
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]##
|``true` if the dialect was set automatically by Quarkus, `false` if it was set explicitly`
620
+
598
621
599
622
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]##
|``true` if the dialect was set automatically by Quarkus, `false` if it was set explicitly`
620
+
598
621
599
622
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]##
Copy file name to clipboardExpand all lines: _versions/main/guides/cdi-integration.adoc
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -419,6 +419,73 @@ public class TestRecorder {
419
419
----
420
420
<1> Pass a contextual reference of `Bar` to the constructor of `Foo`.
421
421
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:
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:
Copy file name to clipboardExpand all lines: _versions/main/guides/qute-reference.adoc
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1710,15 +1710,31 @@ A CDI bean annotated with `@Named` can be referenced in any template through `cd
1710
1710
NOTE: `@Named @Dependent` beans are shared across all expressions in a template for a single rendering operation, and destroyed after the rendering finished.
1711
1711
1712
1712
All expressions with `cdi` and `inject` namespaces are validated during build.
1713
-
1714
1713
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
-
1716
1714
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.
1717
1715
1718
1716
NOTE: A `ValueResolver` is also generated for all beans annotated with `@Named` so that it's possible to access its properties without reflection.
1719
1717
1720
1718
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')}`.
1721
1719
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}`.
0 commit comments