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

spring-di: support scopes on bean methods #2778 #2862

Merged

Conversation

rquinio
Copy link
Contributor

@rquinio rquinio commented Jun 17, 2019

Fixes #2778

  • Fix NPE when org.springframework.context.annotation.Scope is used on a bean method
  • Change default bean implicit scope from dependent to singleton
  • Do not process non-spring annotations (i.e. an explicit singleton) in spring-di, to avoid adding duplicate scopes with Arc processor

- Fix NPE when org.springframework.context.annotation.Scope is used on a bean method
- Change default bean implicit scope from dependent to singleton
- Do not process non-spring annotations (i.e. an explicit singleton) in spring-di, to avoid adding duplicate scopes with Arc processor
* @return A CDI built in (or session) scope that mostly matches
* the spring one. Websocket scope is currently mapped to @Dependant
* and spring custom scopes are not currently handled.
*/
private DotName getScope(final ClassInfo clazz) {
if (!clazz.annotations().containsKey(SPRING_SCOPE_ANNOTATION)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I've changed ClassInfo#annotations() (all levels annotations in the class) to ClassInfo#classAnnotation() (only class-level annotations of the class). The former was causing NPE when trying to access a method-level annotation value via clazz.classAnnotation().value()

@gsmet gsmet requested a review from geoand June 18, 2019 06:20
Copy link
Contributor

@geoand geoand 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 to me, thanks!

Just a couple of comments, which are probably just questions and might not even require changes

@geoand geoand added this to the 0.17.0 milestone Jun 18, 2019
@geoand
Copy link
Contributor

geoand commented Jun 18, 2019

Great stuff, thanks @rquinio!

@geoand geoand merged commit 737ea8c into quarkusio:master Jun 18, 2019
@rquinio rquinio deleted the bugfix/spring-di-bean-method-scopes branch June 18, 2019 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support scopes on @Bean methods in spring-di
2 participants