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

Support injecting a list of Spring beans #5668

Closed
geoand opened this issue Nov 21, 2019 · 5 comments · Fixed by #24883
Closed

Support injecting a list of Spring beans #5668

geoand opened this issue Nov 21, 2019 · 5 comments · Fixed by #24883
Labels
area/spring Issues relating to the Spring integration kind/enhancement New feature or request
Milestone

Comments

@geoand
Copy link
Contributor

geoand commented Nov 21, 2019

Originally brought up by @tpenakov

@geoand geoand added kind/enhancement New feature or request area/spring Issues relating to the Spring integration labels Nov 21, 2019
@rquinio
Copy link
Contributor

rquinio commented Nov 26, 2019

Is this about
spring-DI way @Inject List<MyBean> vs CDI way @Inject javax.enterprise.inject.Instance<MyBean> ?

@tpenakov
Copy link

tpenakov commented Nov 26, 2019

This is the code snipped that does not work in Spring DI module, but works on Spring:
@Autowired List<BaseProcessor> processors;
Here the BaseProcessor class is an abstract class.

@geoand
Copy link
Contributor Author

geoand commented Nov 26, 2019

Yes, in Quarkus one can use @Inject javax.enterprise.inject.Instance<MyBean> while in Spring DI one can do: @Autowired List<MyBean>.

If possible we should provide support for the latter syntax.

@rquinio
Copy link
Contributor

rquinio commented Nov 27, 2019

The behavior is a bit tricky since there can also be producers with return type Collection<MyBean> both in Spring DI and CDI already.

From my quick tests, Spring prefers injecting first the collection of matching MyBean beans, unless there are none - due to @Named, @Qualifier etc. -, in which case it then considers injecting any Collection<MyBean> bean.

CDI (Weld) only considers the Collection<MyBean> bean obviously.

Should it be a change in Arc (to have same defaulting logic as Spring), or rather spring-di extension to re-write the relevant Collection<MyBean> injections points to inject javax.enterprise.inject.Instance<MyBean> and extract the list instead - if that's even possible ?

@geoand
Copy link
Contributor Author

geoand commented Nov 27, 2019

@rquinio the second solution is mostlikely the way to go

geoand added a commit to geoand/quarkus that referenced this issue Apr 12, 2022
This is now possible due to the existence of
Arc's `@All`

Fixes: quarkusio#5668
geoand added a commit to geoand/quarkus that referenced this issue Apr 12, 2022
This is now possible due to the existence of
Arc's `@All`

Fixes: quarkusio#5668
geoand added a commit to geoand/quarkus that referenced this issue Apr 12, 2022
This is now possible due to the existence of
Arc's `@All`

Fixes: quarkusio#5668
geoand added a commit that referenced this issue Apr 12, 2022
Support injecting a list of Spring beans
@quarkus-bot quarkus-bot bot added this to the 2.9 - main milestone Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spring Issues relating to the Spring integration kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants