|
|
|
@ -154,26 +154,35 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { |
|
|
|
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { |
|
|
|
boolean match = super.isAutowireCandidate(bdHolder, descriptor); |
|
|
|
if (!super.isAutowireCandidate(bdHolder, descriptor)) { |
|
|
|
if (match) { |
|
|
|
return false; |
|
|
|
match = checkQualifiers(bdHolder, descriptor.getAnnotations()); |
|
|
|
} |
|
|
|
if (match) { |
|
|
|
Boolean checked = checkQualifiers(bdHolder, descriptor.getAnnotations()); |
|
|
|
MethodParameter methodParam = descriptor.getMethodParameter(); |
|
|
|
if (checked != Boolean.FALSE) { |
|
|
|
if (methodParam != null) { |
|
|
|
MethodParameter methodParam = descriptor.getMethodParameter(); |
|
|
|
Method method = methodParam.getMethod(); |
|
|
|
if (methodParam != null) { |
|
|
|
if (method == null || void.class == method.getReturnType()) { |
|
|
|
Method method = methodParam.getMethod(); |
|
|
|
match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations()); |
|
|
|
if (method == null || void.class == method.getReturnType()) { |
|
|
|
|
|
|
|
Boolean methodChecked = checkQualifiers(bdHolder, methodParam.getMethodAnnotations()); |
|
|
|
|
|
|
|
if (methodChecked != null && checked == null) { |
|
|
|
|
|
|
|
checked = methodChecked; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return match; |
|
|
|
return (checked == Boolean.TRUE || |
|
|
|
|
|
|
|
(checked == null && ((RootBeanDefinition) bdHolder.getBeanDefinition()).isDefaultCandidate())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Match the given qualifier annotations against the candidate bean definition. |
|
|
|
* Match the given qualifier annotations against the candidate bean definition. |
|
|
|
|
|
|
|
* @return {@code false} if a qualifier has been found but not matched, |
|
|
|
|
|
|
|
* {@code true} if a qualifier has been found and matched, |
|
|
|
|
|
|
|
* {@code null} if no qualifier has been found at all |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected boolean checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch) { |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
protected Boolean checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch) { |
|
|
|
boolean qualifierFound = false; |
|
|
|
boolean qualifierFound = false; |
|
|
|
if (!ObjectUtils.isEmpty(annotationsToSearch)) { |
|
|
|
if (!ObjectUtils.isEmpty(annotationsToSearch)) { |
|
|
|
SimpleTypeConverter typeConverter = new SimpleTypeConverter(); |
|
|
|
SimpleTypeConverter typeConverter = new SimpleTypeConverter(); |
|
|
|
@ -217,7 +226,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return (qualifierFound || ((RootBeanDefinition) bdHolder.getBeanDefinition()).isDefaultCandidate()); |
|
|
|
return (qualifierFound ? true : null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|