Skip to content

SPR-10548 - #442

Closed
snicoll wants to merge 2 commits into
spring-projects:masterfrom
snicoll:SPR-10548
Closed

snicoll wants to merge 2 commits into
spring-projects:masterfrom
snicoll:SPR-10548

Conversation

@snicoll

@snicoll snicoll commented Jan 17, 2014

Copy link
Copy Markdown
Member

This adds support for javax.annotation.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.

This PR also improves the test coverage of determinePrimaryCandidate

There is still a problem to be discussed concerning some fallback code that was initially present in determinePrimaryCandidate and that has been moved to determineAutowireCandidate as it is not obvious which use case it covers.

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
@snicoll

snicoll commented Mar 31, 2014

Copy link
Copy Markdown
Member Author

Merged

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.

1 participant