Repository navigation
Conversation
Added tests checking the behaviour of autowiring by type when the @primary annotation is present on the class. Fixed also some inconsistencies in the code.
This adds support for @priority to filter multiple candidates for autowiring. When multiple candidates are available for a given bean, the bean annotated with @primary is used. If none exists, the one with the higher value for the @priority annotation is used. If two beans have the same priority a NoUniqueBeanDefinitionException is thrown, just as if two beans are annotated with @primary. The underlying code for #getBean and #resolveDependency has been merged as this feature is available for both dependency injection and bean lookup by type. Issue: SPR-10548
Member
Author
|
Merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for
javax.annotation.Priorityto filter multiple candidates for autowiring. When multiple candidates are available for a given bean, the bean annotated with@Primaryis used. If none exists, the one with the higher value for the@Priorityannotation is used. If two beans have the same priority aNoUniqueBeanDefinitionExceptionis thrown, just as if two beans are annotated with@Primary.The underlying code for
getBeanandresolveDependencyhas been merged as this feature is available for both dependency injection and bean lookup by type.This PR also improves the test coverage of
determinePrimaryCandidateThere is still a problem to be discussed concerning some fallback code that was initially present in
determinePrimaryCandidateand that has been moved todetermineAutowireCandidateas it is not obvious which use case it covers.