Browse Source

Do not consider all @Components as configuration

Update ConfigurationClassUtils to only consider beans with @Bean
methods as 'lite' configuration candidates.

Prior to this commit all @Component beans were considered 'lite'
configuration candidates which could result in a large number of
ConfigurationClass instance being created that would ultimately be
ignored.

Issue: SPR-10609
pull/299/head
Phillip Webb 13 years ago
parent
commit
2ecc51f066
  1. 2
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java
  2. 6
      spring-context/src/test/java/org/springframework/context/annotation/componentscan/simple/SimpleComponent.java

2
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java

@ -27,7 +27,6 @@ import org.springframework.core.type.AnnotationMetadata; @@ -27,7 +27,6 @@ import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.stereotype.Component;
/**
* Utilities for processing @{@link Configuration} classes.
@ -105,7 +104,6 @@ abstract class ConfigurationClassUtils { @@ -105,7 +104,6 @@ abstract class ConfigurationClassUtils {
return false; // do not consider an interface or an annotation
}
return metadata.isAnnotated(Import.class.getName()) ||
metadata.isAnnotated(Component.class.getName()) ||
metadata.hasAnnotatedMethods(Bean.class.getName());
}

6
spring-context/src/test/java/org/springframework/context/annotation/componentscan/simple/SimpleComponent.java

@ -16,9 +16,15 @@ @@ -16,9 +16,15 @@
package org.springframework.context.annotation.componentscan.simple;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Component
public class SimpleComponent {
@Bean
public String exampleBean() {
return "example";
}
}

Loading…
Cancel
Save