spring-projects/spring-framework — pull request #442 by snicoll (2014-01-17 13:39:56+00:00)
Title: SPR-10548

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.