Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArC docs: mention @Inject @All List<> in section about unused beans #42837

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/src/main/asciidoc/cdi-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,17 @@

An _unremovable_ bean:

* is excluded from removal by an extension, or
* is <<eliminate_false_positives,excluded from removal>>, or
* has a name designated via `@Named`, or
* declares an observer method.

An _unused_ bean:

* is not _unremovable_, and
* is not eligible for injection to any injection point in the dependency tree, and
* is not eligible for injection to any injection point in the dependency tree of _unremovable_ beans, and
* does not declare any producer which is eligible for injection to any injection point in the dependency tree, and

Check warning on line 449 in docs/src/main/asciidoc/cdi-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'.", "location": {"path": "docs/src/main/asciidoc/cdi-reference.adoc", "range": {"start": {"line": 449, "column": 14}}}, "severity": "INFO"}
* is not eligible for injection into any `jakarta.enterprise.inject.Instance` or `jakarta.inject.Provider` injection point.
* is not eligible for injection into any `jakarta.enterprise.inject.Instance` or `jakarta.inject.Provider` injection point, and
* is not eligible for injection into any <<injecting-multiple-bean-instances-intuitively,`@Inject @All List<>`>> injection point.

Unused interceptors and decorators are not associated with any bean.

Expand Down Expand Up @@ -955,9 +956,10 @@
}
----

[[injecting-multiple-bean-instances-intuitively]]

Check warning on line 959 in docs/src/main/asciidoc/cdi-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in '4.17. Injecting Multiple Bean Instances Intuitively'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in '4.17. Injecting Multiple Bean Instances Intuitively'.", "location": {"path": "docs/src/main/asciidoc/cdi-reference.adoc", "range": {"start": {"line": 959, "column": 33}}}, "severity": "INFO"}

Check warning on line 959 in docs/src/main/asciidoc/cdi-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.HeadingPunctuation] Do not use end punctuation in headings. Raw Output: {"message": "[Quarkus.HeadingPunctuation] Do not use end punctuation in headings.", "location": {"path": "docs/src/main/asciidoc/cdi-reference.adoc", "range": {"start": {"line": 959, "column": 33}}}, "severity": "INFO"}
=== Injecting Multiple Bean Instances Intuitively

In CDI, it's possible to inject multiple bean instances (aka contextual references) via the `jakarta.enterprise.inject.Instance` which implements `java.lang.Iterable`.

Check failure on line 962 in docs/src/main/asciidoc/cdi-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsErrors] Use 'you' rather than 'i'. Raw Output: {"message": "[Quarkus.TermsErrors] Use 'you' rather than 'i'.", "location": {"path": "docs/src/main/asciidoc/cdi-reference.adoc", "range": {"start": {"line": 962, "column": 9}}}, "severity": "ERROR"}

Check warning on line 962 in docs/src/main/asciidoc/cdi-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsWarnings] Consider using 'through', 'by', 'from', 'on', or 'by using' rather than 'via' unless updating existing content that uses the term. Raw Output: {"message": "[Quarkus.TermsWarnings] Consider using 'through', 'by', 'from', 'on', or 'by using' rather than 'via' unless updating existing content that uses the term.", "location": {"path": "docs/src/main/asciidoc/cdi-reference.adoc", "range": {"start": {"line": 962, "column": 67}}}, "severity": "WARNING"}
However, it's not exactly intuitive.
Therefore, a new way was introduced in Quarkus - you can inject a `java.util.List` annotated with the `io.quarkus.arc.All` qualifier.
The type of elements in the list is used as the required type when performing the lookup.
Expand Down