Commit 434fb6e9 by saga Committed by Ryan Baxter

Refactor the getScanner method of the FeignClientsRegistrar class (#2559)

parent 90094b6b
...@@ -59,6 +59,7 @@ import org.springframework.util.StringUtils; ...@@ -59,6 +59,7 @@ import org.springframework.util.StringUtils;
* @author Spencer Gibb * @author Spencer Gibb
* @author Jakub Narloch * @author Jakub Narloch
* @author Venil Noronha * @author Venil Noronha
* @author Gang Li
*/ */
class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar, class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware { ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware {
...@@ -278,35 +279,15 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar, ...@@ -278,35 +279,15 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
protected ClassPathScanningCandidateComponentProvider getScanner() { protected ClassPathScanningCandidateComponentProvider getScanner() {
return new ClassPathScanningCandidateComponentProvider(false, this.environment) { return new ClassPathScanningCandidateComponentProvider(false, this.environment) {
@Override @Override
protected boolean isCandidateComponent( protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
AnnotatedBeanDefinition beanDefinition) { boolean isCandidate = false;
if (beanDefinition.getMetadata().isIndependent()) { if (beanDefinition.getMetadata().isIndependent()) {
// TODO until SPR-11711 will be resolved if (!beanDefinition.getMetadata().isAnnotation()) {
if (beanDefinition.getMetadata().isInterface() isCandidate = true;
&& beanDefinition.getMetadata()
.getInterfaceNames().length == 1
&& Annotation.class.getName().equals(beanDefinition
.getMetadata().getInterfaceNames()[0])) {
try {
Class<?> target = ClassUtils.forName(
beanDefinition.getMetadata().getClassName(),
FeignClientsRegistrar.this.classLoader);
return !target.isAnnotation();
}
catch (Exception ex) {
this.logger.error(
"Could not load target class: "
+ beanDefinition.getMetadata().getClassName(),
ex);
}
} }
return true;
} }
return false; return isCandidate;
} }
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment