Search in sources :

Example 81 with AnnotationAttributes

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);
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 82 with AnnotationAttributes

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;
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 83 with AnnotationAttributes

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);
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) Test(org.junit.jupiter.api.Test)

Example 84 with AnnotationAttributes

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);
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) Test(org.junit.jupiter.api.Test)

Example 85 with AnnotationAttributes

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);
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) Test(org.junit.jupiter.api.Test)

Aggregations

AnnotationAttributes (org.springframework.core.annotation.AnnotationAttributes)89 Test (org.junit.jupiter.api.Test)17 ArrayList (java.util.ArrayList)8 LinkedHashSet (java.util.LinkedHashSet)7 AnnotationMetadata (org.springframework.core.type.AnnotationMetadata)7 Annotation (java.lang.annotation.Annotation)6 Method (java.lang.reflect.Method)6 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)3 ConditionOutcome (org.springframework.boot.autoconfigure.condition.ConditionOutcome)3 StandardAnnotationMetadata (org.springframework.core.type.StandardAnnotationMetadata)3 DubboReference (org.apache.dubbo.config.annotation.DubboReference)2 ReferenceBean (org.apache.dubbo.config.spring.ReferenceBean)2 Test (org.junit.Test)2 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)2 BeanNameGenerator (org.springframework.beans.factory.support.BeanNameGenerator)2 DiscoveredOperationMethod (org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod)2 ContextConfiguration (org.springframework.test.context.ContextConfiguration)2