use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class AutoConfigurationImportSelector method getAutoConfigurationEntry.
/**
* Return the {@link AutoConfigurationEntry} based on the {@link AnnotationMetadata}
* of the importing {@link Configuration @Configuration} class.
* @param annotationMetadata the annotation metadata of the configuration class
* @return the auto-configurations that should be imported
*/
protected AutoConfigurationEntry getAutoConfigurationEntry(AnnotationMetadata annotationMetadata) {
if (!isEnabled(annotationMetadata)) {
return EMPTY_ENTRY;
}
AnnotationAttributes attributes = getAttributes(annotationMetadata);
List<String> configurations = getCandidateConfigurations(annotationMetadata, attributes);
configurations = removeDuplicates(configurations);
Set<String> exclusions = getExclusions(annotationMetadata, attributes);
checkExcludedClasses(configurations, exclusions);
configurations.removeAll(exclusions);
configurations = getConfigurationClassFilter().filter(configurations);
fireAutoConfigurationImportEvents(configurations, exclusions);
return new AutoConfigurationEntry(configurations, exclusions);
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class AutoConfigurationImportSelector method getAttributes.
/**
* Return the appropriate {@link AnnotationAttributes} from the
* {@link AnnotationMetadata}. By default this method will return attributes for
* {@link #getAnnotationClass()}.
* @param metadata the annotation metadata
* @return annotation attributes
*/
protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) {
String name = getAnnotationClass().getName();
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(name, true));
Assert.notNull(attributes, () -> "No auto-configuration attributes found. Is " + metadata.getClassName() + " annotated with " + ClassUtils.getShortName(name) + "?");
return attributes;
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class SpringBootApplicationTests method nameGeneratorCanBeSpecified.
@Test
void nameGeneratorCanBeSpecified() {
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(CustomNameGeneratorConfiguration.class, ComponentScan.class);
assertThat(attributes.get("nameGenerator")).isEqualTo(TestBeanNameGenerator.class);
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class TestConfigurationTests method proxyBeanMethodsIsEnabledByDefault.
@Test
void proxyBeanMethodsIsEnabledByDefault() {
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(DefaultTestConfiguration.class, Configuration.class);
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(true);
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class TestConfigurationTests method proxyBeanMethodsCanBeDisabled.
@Test
void proxyBeanMethodsCanBeDisabled() {
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(NoBeanMethodProxyingTestConfiguration.class, Configuration.class);
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(false);
}
Aggregations