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

Add convenient ArcContainer.listAll() methods #25061

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

mkouba
Copy link
Contributor

@mkouba mkouba commented Apr 21, 2022

  • i.e. programmatic lookup for io.quarkus.arc.All

@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/documentation labels Apr 21, 2022
@mkouba
Copy link
Contributor Author

mkouba commented Apr 21, 2022

Previously you'd need to use something like Arc.container().instance(new TypeLiteral<List<Service>>() {}, All.Literal.INSTANCE).get() or even Arc.container().instance(new TypeLiteral<List<InstanceHandle<Service>>>() {}, All.Literal.INSTANCE).get() if you want to destroy the @Dependent beans correctly.

Copy link
Contributor

@Ladicek Ladicek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Out of curiosity, is this basically identical to InjectableInstance.select(...).handles()?

@mkouba
Copy link
Contributor Author

mkouba commented Apr 21, 2022

Out of curiosity, is this basically identical to InjectableInstance.select(...).handles()?

More or less, but handles() returns an Iterable and not a List. Also you'd have to use the TypeLiteral and the @All qualifier for regular select().

@Ladicek
Copy link
Contributor

Ladicek commented Apr 21, 2022

Ah ah, I see, so ArcContainer.listAll(type, qualifiers) is roughly identical to InjectableInstance.select(List<type>, All.Literal.INSTANCE + qualifiers).handles(), got it. Thanks!

@mkouba mkouba force-pushed the arc-container-list-all branch from 20b85ba to 5f77cfc Compare April 21, 2022 09:58
@mkouba mkouba added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Apr 21, 2022
@quarkus-bot

This comment has been minimized.

@mkouba mkouba force-pushed the arc-container-list-all branch from 5f77cfc to 44249d1 Compare April 21, 2022 10:11
Copy link
Contributor

@manovotn manovotn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

- i.e. programmatic lookup for io.quarkus.arc.All

Co-authored-by: Matej Novotny <[email protected]>
@mkouba mkouba force-pushed the arc-container-list-all branch from 88b4be7 to ad10241 Compare April 21, 2022 13:47
@quarkus-bot

This comment has been minimized.

@mkouba mkouba merged commit 5b62f7b into quarkusio:main Apr 22, 2022
@quarkus-bot quarkus-bot bot added this to the 2.9 - main milestone Apr 22, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants