Search in sources :

Example 26 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.

the class SpringBootConfigurationTests method proxyBeanMethodsCanBeDisabled.

@Test
void proxyBeanMethodsCanBeDisabled() {
    AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(NoBeanMethodProxyingSpringBootConfiguration.class, Configuration.class);
    assertThat(attributes.get("proxyBeanMethods")).isEqualTo(false);
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) Test(org.junit.jupiter.api.Test)

Example 27 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.

the class ServletComponentScanRegistrar method getPackagesToScan.

private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(ServletComponentScan.class.getName()));
    String[] basePackages = attributes.getStringArray("basePackages");
    Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
    Set<String> packagesToScan = new LinkedHashSet<>(Arrays.asList(basePackages));
    for (Class<?> basePackageClass : basePackageClasses) {
        packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
    }
    if (packagesToScan.isEmpty()) {
        packagesToScan.add(ClassUtils.getPackageName(metadata.getClassName()));
    }
    return packagesToScan;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 28 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.

the class ServletComponentHandler method extractInitParameters.

protected final Map<String, String> extractInitParameters(Map<String, Object> attributes) {
    Map<String, String> initParameters = new HashMap<>();
    for (AnnotationAttributes initParam : (AnnotationAttributes[]) attributes.get("initParams")) {
        String name = (String) initParam.get("name");
        String value = (String) initParam.get("value");
        initParameters.put(name, value);
    }
    return initParameters;
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) HashMap(java.util.HashMap)

Example 29 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.

the class SpringBootApplicationTests method proxyBeanMethodsCanBeDisabled.

@Test
void proxyBeanMethodsCanBeDisabled() {
    AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(NoBeanMethodProxyingSpringBootApplication.class, Configuration.class);
    assertThat(attributes.get("proxyBeanMethods")).isEqualTo(false);
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) Test(org.junit.jupiter.api.Test)

Example 30 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.

the class SpringBootApplicationTests method proxyBeanMethodsIsEnabledByDefault.

@Test
void proxyBeanMethodsIsEnabledByDefault() {
    AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(DefaultSpringBootApplication.class, Configuration.class);
    assertThat(attributes.get("proxyBeanMethods")).isEqualTo(true);
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) Test(org.junit.jupiter.api.Test)

Aggregations

AnnotationAttributes (org.springframework.core.annotation.AnnotationAttributes)90 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)4 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 PropertySourcesProcessor (com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor)2 SpringValueDefinitionProcessor (com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor)2 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