Skip to content

Commit

Permalink
Sync web site with Quarkus documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Oct 13, 2023
1 parent cfafe82 commit 95beecc
Show file tree
Hide file tree
Showing 41 changed files with 140 additions and 91 deletions.
22 changes: 16 additions & 6 deletions _data/versioned/latest/index/quarkus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ types:
- title: Contexts and Dependency Injection
filename: cdi-reference.adoc
summary: Go more in depth into the Quarkus implementation of CDI.
keywords: arc
categories: core
type: reference
url: /guides/cdi-reference
Expand All @@ -55,7 +56,7 @@ types:
- title: Logging configuration
filename: logging.adoc
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."
categories: "core, getting-started, observability"
categories: "getting-started, core, observability"
id: logging
type: reference
url: /guides/logging
Expand Down Expand Up @@ -173,6 +174,7 @@ types:
- title: Configuring Well-Known OpenID Connect Providers
filename: security-openid-connect-providers.adoc
summary: This document explains how to configure well-known social OIDC and OAuth2 providers.
keywords: oidc github twitter google facebook mastodon microsoft apple spotify twitch
categories: "security, web"
id: security-openid-connect-providers
type: concepts
Expand Down Expand Up @@ -236,7 +238,7 @@ types:
- title: Security vulnerability detection and reporting in Quarkus
filename: security-vulnerability-detection.adoc
summary: Most of the Quarkus tags are registered in the US National Vulnerability Database (NVD) in Common Platform Enumeration (CPE) name format.
categories: "contributing, security"
categories: "security, contributing"
id: security-vulnerability-detection
type: concepts
url: /guides/security-vulnerability-detection
Expand Down Expand Up @@ -265,15 +267,15 @@ types:
- title: Use virtual threads in REST applications
filename: resteasy-reactive-virtual-threads.adoc
summary: How to use virtual threads in a REST application
categories: "core, web"
categories: "web, core"
id: resteasy-reactive-virtual-threads
type: howto
url: /guides/resteasy-reactive-virtual-threads
tutorial:
- title: Building a Native Executable
filename: building-native-image.adoc
summary: Build native executables with GraalVM or Mandrel.
categories: "native, getting-started"
categories: "getting-started, native"
type: tutorial
url: /guides/building-native-image
- title: Collect metrics using Micrometer
Expand Down Expand Up @@ -338,7 +340,7 @@ types:
- title: Your second Quarkus application
filename: getting-started-dev-services.adoc
summary: Discover some of the features that make developing with Quarkus a joyful experience.
categories: "core, getting-started, data"
categories: "getting-started, data, core"
id: getting-started-dev-services-tutorial
type: tutorial
url: /guides/getting-started-dev-services
Expand Down Expand Up @@ -406,6 +408,7 @@ types:
- title: Application Initialization and Termination
filename: lifecycle.adoc
summary: You often need to execute custom actions when the application starts and clean up everything when the application stops.
keywords: lifecycle event
categories: core
type: guide
url: /guides/lifecycle
Expand Down Expand Up @@ -565,6 +568,7 @@ types:
- title: Dev Services and UI for OpenID Connect (OIDC)
filename: security-openid-connect-dev-services.adoc
summary: Start Keycloak or other providers automatically in dev and test modes.
keywords: sso oidc security keycloak
categories: security
type: guide
url: /guides/security-openid-connect-dev-services
Expand Down Expand Up @@ -789,6 +793,7 @@ types:
- title: Introduction to Contexts and Dependency Injection (CDI)
filename: cdi.adoc
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."
keywords: qualifier event interceptor observer arc
categories: core
type: guide
url: /guides/cdi
Expand Down Expand Up @@ -1087,7 +1092,7 @@ types:
- title: Testing Your Application
filename: getting-started-testing.adoc
summary: "This guide covers testing in JVM mode, native mode, and injection of resources into tests"
categories: "native, tooling, core"
categories: "tooling, native, core"
id: testing
type: guide
url: /guides/getting-started-testing
Expand Down Expand Up @@ -1154,6 +1159,8 @@ types:
- title: Using Keycloak Admin Client
filename: security-keycloak-admin-client.adoc
summary: The Quarkus Keycloak Admin Client and its reactive twin support Keycloak Admin Client which can be used to configure a running Keycloak server.
keywords: sso oidc security keycloak
categories: security
type: guide
url: /guides/security-keycloak-admin-client
- title: Using Kotlin
Expand All @@ -1176,6 +1183,7 @@ types:
- title: Using OAuth2 RBAC
filename: security-oauth2.adoc
summary: This guide explains how your Quarkus application can utilize OAuth2 tokens to provide secured access to the Jakarta REST endpoints.
keywords: oauth
categories: security
type: guide
url: /guides/security-oauth2
Expand All @@ -1188,12 +1196,14 @@ types:
- title: Using OpenID Connect (OIDC) Multi-Tenancy
filename: security-openid-connect-multitenancy.adoc
summary: This guide demonstrates how your OpenID Connect application can support multi-tenancy so that you can serve multiple tenants from a single application.
keywords: sso oidc oauth2 security
categories: security
type: guide
url: /guides/security-openid-connect-multitenancy
- title: Using OpenID Connect (OIDC) and Keycloak to Centralize Authorization
filename: security-keycloak-authorization.adoc
summary: This guide demonstrates how your Quarkus application can authorize access to protected resources using Keycloak Authorization Services.
keywords: sso oidc security keycloak
categories: security
type: guide
url: /guides/security-keycloak-authorization
Expand Down
2 changes: 1 addition & 1 deletion _guides/_attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Common attributes.
// --> No blank lines (it ends the document header)
:project-name: Quarkus
:quarkus-version: 3.4.2
:quarkus-version: 3.4.3
:quarkus-platform-groupid: io.quarkus.platform
// .
:maven-version: 3.9.3
Expand Down
5 changes: 5 additions & 0 deletions _guides/ansible.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
////
This guide is maintained in the main Quarkus repository
and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
////
= Automate Quarkus deployment with Ansible
include::_attributes.adoc[]
:categories: command-line
Expand Down
1 change: 1 addition & 0 deletions _guides/cdi-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
= Contexts and Dependency Injection
include::_attributes.adoc[]
:categories: core
:keywords: arc
:summary: Go more in depth into the Quarkus implementation of CDI.
:numbered:
:sectnums:
Expand Down
71 changes: 36 additions & 35 deletions _guides/cdi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
= Introduction to Contexts and Dependency Injection (CDI)
include::_attributes.adoc[]
:categories: core
:keywords: qualifier event interceptor observer arc
: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.
:numbered:
:sectnums:
Expand All @@ -28,7 +29,7 @@ It creates and destroys the instances of beans, associates the instances with a

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.

NOTE: You've probably heard of the _inversion of control_ (IoC) programming principle. Dependency injection is one of the implementation techniques of IoC.
NOTE: You've probably heard of the _inversion of control_ (IoC) programming principle. Dependency injection is one of the implementation techniques of IoC.

== What does a bean look like?

Expand All @@ -47,9 +48,9 @@ public class Translator {
@Inject
Dictionary dictionary; <2>
@Counted <3>
String translate(String sentence) {
String translate(String sentence) {
// ...
}
}
Expand Down Expand Up @@ -86,8 +87,8 @@ public class Translator {
@Inject
Instance<Dictionary> dictionaries; <1>
String translate(String sentence) {
String translate(String sentence) {
for (Dictionary dict : dictionaries) { <2>
// ...
}
Expand Down Expand Up @@ -122,11 +123,11 @@ public class Translator {
}
}
----
<1> This is a constructor injection.
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`.
<1> This is a constructor injection.
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`.
However, in Quarkus we detect the absence of no-args constructor and "add" it directly in the bytecode.
It's also not necessary to add `@Inject` if there is only one constructor present.
<2> An initializer method must be annotated with `@Inject`.
<2> An initializer method must be annotated with `@Inject`.
<3> An initializer may accept multiple parameters - each one is an injection point.

== You talked about some qualifiers?
Expand Down Expand Up @@ -155,7 +156,7 @@ The qualifiers of a bean are declared by annotating the bean class or producer m
@ApplicationScoped
public class SuperiorTranslator extends Translator {
String translate(String sentence) {
String translate(String sentence) {
// ...
}
}
Expand All @@ -180,11 +181,11 @@ You can use all the built-in scopes mentioned by the specification except for `j

[options="header",cols="1,1"]
|===
|Annotation |Description
|Annotation |Description
//----------------------
|`@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].
|`@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].
|`@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.
|`@jakarta.enterprise.context.RequestScoped` | The bean instance is associated with the current _request_ (usually an HTTP request).
|`@jakarta.enterprise.context.RequestScoped` | The bean instance is associated with the current _request_ (usually an HTTP request).
|`@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.
|`@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.
|===
Expand Down Expand Up @@ -217,23 +218,23 @@ Indeed, the https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#
A client proxy is basically an object that delegates all method invocations to a target bean instance.
It's a container construct that implements `io.quarkus.arc.ClientProxy` and extends the bean class.
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.
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.
.Generated Client Proxy Example
[source,java]
----
@ApplicationScoped
class Translator {

String translate(String sentence) {
String translate(String sentence) {
// ...
}
}

// The client proxy class is generated and looks like...
class Translator_ClientProxy extends Translator { <1>

String translate(String sentence) {
String translate(String sentence) {
// Find the correct translator instance...
Translator translator = getTranslatorInstanceFromTheApplicationContext();
// And delegate the method invocation...
Expand All @@ -247,10 +248,10 @@ Client proxies allow for:
* Lazy instantiation - the instance is created once a method is invoked upon the proxy.
* 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.
* Circular dependencies in the dependency graph. Having circular dependencies is often an indication that a redesign should be considered, but sometimes it's inevitable.
* Circular dependencies in the dependency graph. Having circular dependencies is often an indication that a redesign should be considered, but sometimes it's inevitable.
* In rare cases it's practical to destroy the beans manually. A direct injected reference would lead to a stale bean instance.
== OK. You said that there are several kinds of beans?
Yes. In general, we distinguish:
Expand All @@ -273,7 +274,7 @@ public class Producers {

@Produces <1>
double pi = Math.PI; <2>

@Produces <3>
List<String> names() {
List<String> names = new ArrayList<>();
Expand All @@ -289,26 +290,26 @@ public class Consumer {

@Inject
double pi;

@Inject
List<String> names;
// ...
}

// ...
}
----
<1> The container analyses the field annotations to build a bean metadata.
The _type_ is used to build the set of bean types.
The _type_ is used to build the set of bean types.
In this case, it will be `double` and `java.lang.Object`.
No scope annotation is declared and so it's defaulted to `@Dependent`.
<2> The container will read this field when creating the bean instance.
<3> The container analyses the method annotations to build a bean metadata.
The _return type_ is used to build the set of bean types.
The _return type_ is used to build the set of bean types.
In this case, it will be `List<String>`, `Collection<String>`, `Iterable<String>` and `java.lang.Object`.
No scope annotation is declared and so it's defaulted to `@Dependent`.
<4> The container will call this method when creating the bean instance.
There's more about producers.
You can declare qualifiers, inject dependencies into the producer methods parameters, etc.
There's more about producers.
You can declare qualifiers, inject dependencies into the producer methods parameters, etc.
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"].
== OK, injection looks cool. What other services are provided?
Expand All @@ -330,7 +331,7 @@ public class Translator {
void init() {
// ...
}

@PreDestroy <2>
void destroy() {
// ...
Expand All @@ -345,7 +346,7 @@ TIP: It's a good practice to keep the logic in the callbacks "without side effec
[[interceptors]]
=== Interceptors
Interceptors are used to separate cross-cutting concerns from business logic.
Interceptors are used to separate cross-cutting concerns from business logic.
There is a separate specification - Java Interceptors - that defines the basic programming model and semantics.
.Simple Interceptor Binding Example
Expand Down Expand Up @@ -392,11 +393,11 @@ public class LoggingInterceptor {
// ...log after
return ret;
}

}
----
<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.
<2> `Priority` enables the interceptor and affects the interceptor ordering. Interceptors with smaller priority values are called first.
<2> `Priority` enables the interceptor and affects the interceptor ordering. Interceptors with smaller priority values are called first.
<3> Marks an interceptor component.
<4> An interceptor may inject dependencies.
<5> `AroundInvoke` denotes a method that interposes on business methods.
Expand Down Expand Up @@ -448,7 +449,7 @@ public class LargeTxAccount implements Account { <3>
@Any
@Delegate
Account delegate; <4>

@Inject
LogService logService; <5>

Expand All @@ -458,10 +459,10 @@ public class LargeTxAccount implements Account { <3>
logService.logWithdrawal(delegate, amount);
}
}

}
----
<1> `@Priority` enables the decorator. Decorators with smaller priority values are called first.
<1> `@Priority` enables the decorator. Decorators with smaller priority values are called first.
<2> `@Decorator` marks a decorator component.
<3> The set of decorated types includes all bean types which are Java interfaces, except for `java.io.Serializable`.
<4> Each decorator must declare exactly one _delegate injection point_. The decorator applies to beans that are assignable to this delegate injection point.
Expand All @@ -471,7 +472,7 @@ public class LargeTxAccount implements Account { <3>
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.
=== Events and Observers
Beans may also produce and consume events to interact in a completely decoupled fashion.
Any Java object can serve as an event payload.
The optional qualifiers act as topic selectors.
Expand Down
Loading

0 comments on commit 95beecc

Please sign in to comment.