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
Copy file name to clipboardExpand all lines: _data/versioned/latest/index/quarkus.yaml
+16-6
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ types:
37
37
- title: Contexts and Dependency Injection
38
38
filename: cdi-reference.adoc
39
39
summary: Go more in depth into the Quarkus implementation of CDI.
40
+
keywords: arc
40
41
categories: core
41
42
type: reference
42
43
url: /guides/cdi-reference
@@ -55,7 +56,7 @@ types:
55
56
- title: Logging configuration
56
57
filename: logging.adoc
57
58
summary: "Read about the use of logging API in Quarkus, configuring logging output, and using logging adapters to unify the output from other logging APIs."
summary: Start Keycloak or other providers automatically in dev and test modes.
571
+
keywords: sso oidc security keycloak
568
572
categories: security
569
573
type: guide
570
574
url: /guides/security-openid-connect-dev-services
@@ -789,6 +793,7 @@ types:
789
793
- title: Introduction to Contexts and Dependency Injection (CDI)
790
794
filename: cdi.adoc
791
795
summary: "Quarkus DI solution is based on the [Jakarta Contexts and Dependency Injection 4.0](https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html) specification."
summary: "This guide covers testing in JVM mode, native mode, and injection of resources into tests"
1090
-
categories: "native, tooling, core"
1095
+
categories: "tooling, native, core"
1091
1096
id: testing
1092
1097
type: guide
1093
1098
url: /guides/getting-started-testing
@@ -1154,6 +1159,8 @@ types:
1154
1159
- title: Using Keycloak Admin Client
1155
1160
filename: security-keycloak-admin-client.adoc
1156
1161
summary: The Quarkus Keycloak Admin Client and its reactive twin support Keycloak Admin Client which can be used to configure a running Keycloak server.
1162
+
keywords: sso oidc security keycloak
1163
+
categories: security
1157
1164
type: guide
1158
1165
url: /guides/security-keycloak-admin-client
1159
1166
- title: Using Kotlin
@@ -1176,6 +1183,7 @@ types:
1176
1183
- title: Using OAuth2 RBAC
1177
1184
filename: security-oauth2.adoc
1178
1185
summary: This guide explains how your Quarkus application can utilize OAuth2 tokens to provide secured access to the Jakarta REST endpoints.
1186
+
keywords: oauth
1179
1187
categories: security
1180
1188
type: guide
1181
1189
url: /guides/security-oauth2
@@ -1188,12 +1196,14 @@ types:
1188
1196
- title: Using OpenID Connect (OIDC) Multi-Tenancy
summary: This guide demonstrates how your OpenID Connect application can support multi-tenancy so that you can serve multiple tenants from a single application.
1199
+
keywords: sso oidc oauth2 security
1191
1200
categories: security
1192
1201
type: guide
1193
1202
url: /guides/security-openid-connect-multitenancy
1194
1203
- title: Using OpenID Connect (OIDC) and Keycloak to Centralize Authorization
1195
1204
filename: security-keycloak-authorization.adoc
1196
1205
summary: This guide demonstrates how your Quarkus application can authorize access to protected resources using Keycloak Authorization Services.
:summary: Quarkus DI solution is based on the [Jakarta Contexts and Dependency Injection 4.0](https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html) specification. This guide explains the basics of CDI.
10
11
:numbered:
11
12
:sectnums:
@@ -28,7 +29,7 @@ It creates and destroys the instances of beans, associates the instances with a
28
29
29
30
An application developer can focus on the business logic rather than finding out "where and how" to obtain a fully initialized component with all of its dependencies.
30
31
31
-
NOTE: You've probably heard of the _inversion of control_ (IoC) programming principle. Dependency injection is one of the implementation techniques of IoC.
32
+
NOTE: You've probably heard of the _inversion of control_ (IoC) programming principle. Dependency injection is one of the implementation techniques of IoC.
32
33
33
34
== What does a bean look like?
34
35
@@ -47,9 +48,9 @@ public class Translator {
47
48
48
49
@Inject
49
50
Dictionary dictionary; <2>
50
-
51
+
51
52
@Counted <3>
52
-
String translate(String sentence) {
53
+
String translate(String sentence) {
53
54
// ...
54
55
}
55
56
}
@@ -86,8 +87,8 @@ public class Translator {
86
87
87
88
@Inject
88
89
Instance<Dictionary> dictionaries; <1>
89
-
90
-
String translate(String sentence) {
90
+
91
+
String translate(String sentence) {
91
92
for (Dictionary dict : dictionaries) { <2>
92
93
// ...
93
94
}
@@ -122,11 +123,11 @@ public class Translator {
122
123
}
123
124
}
124
125
----
125
-
<1> This is a constructor injection.
126
-
In fact, this code would not work in regular CDI implementations where a bean with a normal scope must always declare a no-args constructor and the bean constructor must be annotated with `@Inject`.
126
+
<1> This is a constructor injection.
127
+
In fact, this code would not work in regular CDI implementations where a bean with a normal scope must always declare a no-args constructor and the bean constructor must be annotated with `@Inject`.
127
128
However, in Quarkus we detect the absence of no-args constructor and "add" it directly in the bytecode.
128
129
It's also not necessary to add `@Inject` if there is only one constructor present.
129
-
<2> An initializer method must be annotated with `@Inject`.
130
+
<2> An initializer method must be annotated with `@Inject`.
130
131
<3> An initializer may accept multiple parameters - each one is an injection point.
131
132
132
133
== You talked about some qualifiers?
@@ -155,7 +156,7 @@ The qualifiers of a bean are declared by annotating the bean class or producer m
155
156
@ApplicationScoped
156
157
public class SuperiorTranslator extends Translator {
157
158
158
-
String translate(String sentence) {
159
+
String translate(String sentence) {
159
160
// ...
160
161
}
161
162
}
@@ -180,11 +181,11 @@ You can use all the built-in scopes mentioned by the specification except for `j
180
181
181
182
[options="header",cols="1,1"]
182
183
|===
183
-
|Annotation |Description
184
+
|Annotation |Description
184
185
//----------------------
185
-
|`@jakarta.enterprise.context.ApplicationScoped` | A single bean instance is used for the application and shared among all injection points. The instance is created lazily, i.e. once a method is invoked upon the xref:client_proxies[client proxy].
186
+
|`@jakarta.enterprise.context.ApplicationScoped` | A single bean instance is used for the application and shared among all injection points. The instance is created lazily, i.e. once a method is invoked upon the xref:client_proxies[client proxy].
186
187
|`@jakarta.inject.Singleton` | Just like `@ApplicationScoped` except that no client proxy is used. The instance is created when an injection point that resolves to a @Singleton bean is being injected.
187
-
|`@jakarta.enterprise.context.RequestScoped` | The bean instance is associated with the current _request_ (usually an HTTP request).
188
+
|`@jakarta.enterprise.context.RequestScoped` | The bean instance is associated with the current _request_ (usually an HTTP request).
188
189
|`@jakarta.enterprise.context.Dependent` | This is a pseudo-scope. The instances are not shared and every injection point spawns a new instance of the dependent bean. The lifecycle of dependent bean is bound to the bean injecting it - it will be created and destroyed along with the bean injecting it.
189
190
|`@jakarta.enterprise.context.SessionScoped` | This scope is backed by a `jakarta.servlet.http.HttpSession` object. It's only available if the `quarkus-undertow` extension is used.
190
191
|===
@@ -217,23 +218,23 @@ Indeed, the https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#
217
218
A client proxy is basically an object that delegates all method invocations to a target bean instance.
218
219
It's a container construct that implements `io.quarkus.arc.ClientProxy` and extends the bean class.
219
220
220
-
IMPORTANT: Client proxies only delegate method invocations. So never read or write a field of a normal scoped bean, otherwise you will work with non-contextual or stale data.
221
+
IMPORTANT: Client proxies only delegate method invocations. So never read or write a field of a normal scoped bean, otherwise you will work with non-contextual or stale data.
221
222
222
223
.Generated Client Proxy Example
223
224
[source,java]
224
225
----
225
226
@ApplicationScoped
226
227
class Translator {
227
228
228
-
String translate(String sentence) {
229
+
String translate(String sentence) {
229
230
// ...
230
231
}
231
232
}
232
233
233
234
// The client proxy class is generated and looks like...
234
235
class Translator_ClientProxy extends Translator { <1>
* Lazy instantiation - the instance is created once a method is invoked upon the proxy.
249
250
* Ability to inject a bean with "narrower" scope to a bean with "wider" scope; i.e. you can inject a `@RequestScoped` bean into an `@ApplicationScoped` bean.
250
-
* Circular dependencies in the dependency graph. Having circular dependencies is often an indication that a redesign should be considered, but sometimes it's inevitable.
251
+
* Circular dependencies in the dependency graph. Having circular dependencies is often an indication that a redesign should be considered, but sometimes it's inevitable.
251
252
* In rare cases it's practical to destroy the beans manually. A direct injected reference would lead to a stale bean instance.
252
-
253
-
253
+
254
+
254
255
== OK. You said that there are several kinds of beans?
255
256
256
257
Yes. In general, we distinguish:
@@ -273,7 +274,7 @@ public class Producers {
273
274
274
275
@Produces <1>
275
276
double pi = Math.PI; <2>
276
-
277
+
277
278
@Produces <3>
278
279
List<String> names() {
279
280
List<String> names = new ArrayList<>();
@@ -289,26 +290,26 @@ public class Consumer {
289
290
290
291
@Inject
291
292
double pi;
292
-
293
+
293
294
@Inject
294
295
List<String> names;
295
-
296
-
// ...
297
-
}
296
+
297
+
// ...
298
+
}
298
299
----
299
300
<1> The container analyses the field annotations to build a bean metadata.
300
-
The _type_ is used to build the set of bean types.
301
+
The _type_ is used to build the set of bean types.
301
302
In this case, it will be `double` and `java.lang.Object`.
302
303
No scope annotation is declared and so it's defaulted to `@Dependent`.
303
304
<2> The container will read this field when creating the bean instance.
304
305
<3> The container analyses the method annotations to build a bean metadata.
305
-
The _return type_ is used to build the set of bean types.
306
+
The _return type_ is used to build the set of bean types.
306
307
In this case, it will be `List<String>`, `Collection<String>`, `Iterable<String>` and `java.lang.Object`.
307
308
No scope annotation is declared and so it's defaulted to `@Dependent`.
308
309
<4> The container will call this method when creating the bean instance.
309
310
310
-
There's more about producers.
311
-
You can declare qualifiers, inject dependencies into the producer methods parameters, etc.
311
+
There's more about producers.
312
+
You can declare qualifiers, inject dependencies into the producer methods parameters, etc.
312
313
You can read more about producers for example in the https://docs.jboss.org/weld/reference/latest/en-US/html/producermethods.html[Weld docs, window="_blank"].
313
314
314
315
== OK, injection looks cool. What other services are provided?
@@ -330,7 +331,7 @@ public class Translator {
330
331
void init() {
331
332
// ...
332
333
}
333
-
334
+
334
335
@PreDestroy <2>
335
336
void destroy() {
336
337
// ...
@@ -345,7 +346,7 @@ TIP: It's a good practice to keep the logic in the callbacks "without side effec
345
346
[[interceptors]]
346
347
=== Interceptors
347
348
348
-
Interceptors are used to separate cross-cutting concerns from business logic.
349
+
Interceptors are used to separate cross-cutting concerns from business logic.
349
350
There is a separate specification - Java Interceptors - that defines the basic programming model and semantics.
350
351
351
352
.Simple Interceptor Binding Example
@@ -392,11 +393,11 @@ public class LoggingInterceptor {
392
393
// ...log after
393
394
return ret;
394
395
}
395
-
396
+
396
397
}
397
398
----
398
399
<1> The interceptor binding annotation is used to bind our interceptor to a bean. Simply annotate a bean class with `@Logged`, as in the following example.
399
-
<2> `Priority` enables the interceptor and affects the interceptor ordering. Interceptors with smaller priority values are called first.
400
+
<2> `Priority` enables the interceptor and affects the interceptor ordering. Interceptors with smaller priority values are called first.
400
401
<3> Marks an interceptor component.
401
402
<4> An interceptor may inject dependencies.
402
403
<5> `AroundInvoke` denotes a method that interposes on business methods.
@@ -448,7 +449,7 @@ public class LargeTxAccount implements Account { <3>
448
449
@Any
449
450
@Delegate
450
451
Account delegate; <4>
451
-
452
+
452
453
@Inject
453
454
LogService logService; <5>
454
455
@@ -458,10 +459,10 @@ public class LargeTxAccount implements Account { <3>
458
459
logService.logWithdrawal(delegate, amount);
459
460
}
460
461
}
461
-
462
+
462
463
}
463
464
----
464
-
<1> `@Priority` enables the decorator. Decorators with smaller priority values are called first.
465
+
<1> `@Priority` enables the decorator. Decorators with smaller priority values are called first.
465
466
<2> `@Decorator` marks a decorator component.
466
467
<3> The set of decorated types includes all bean types which are Java interfaces, except for `java.io.Serializable`.
467
468
<4> Each decorator must declare exactly one _delegate injection point_. The decorator applies to beans that are assignable to this delegate injection point.
@@ -471,7 +472,7 @@ public class LargeTxAccount implements Account { <3>
471
472
NOTE: Instances of decorators are dependent objects of the bean instance they intercept, i.e. a new decorator instance is created for each intercepted bean.
472
473
473
474
=== Events and Observers
474
-
475
+
475
476
Beans may also produce and consume events to interact in a completely decoupled fashion.
0 commit comments