-
Notifications
You must be signed in to change notification settings - Fork 25
Determine Priority Annotations at Compile Time #852
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
Conversation
- read the annotations at compile time - simplify bean matching logic - can use priority on factory beans now
@@ -526,7 +533,7 @@ boolean isLazy() { | |||
} | |||
|
|||
boolean isUseProviderForSecondary() { | |||
return secondary && !optionalType && !Util.isProvider(returnTypeRaw); | |||
return (secondary || priority != null) && !optionalType && !Util.isProvider(returnTypeRaw); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if it's got a @Priority
also wire as Provider<T>
which has the effect of only instantiating when needed.
Needed by .. being the highest priority or BeanScope#list or injecting a List/Set/Map of that type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the appearance of a priority annotation invites the possibility that a higher priority bean might exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this PR.
I think it's nice to merge the Priority in with Primary and Secondary.
@Priority
annotations at compile time@Primary
/@Secondary
beans@Priority
on factory@Bean
methodsResolves #854