Search in sources :

Example 11 with AnnotationAttributes

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

the class AnnotationMetadataReadingVisitor method getAllAnnotationAttributes.

@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
    MultiValueMap<String, Object> allAttributes = new LinkedMultiValueMap<>();
    List<AnnotationAttributes> attributes = this.attributesMap.get(annotationName);
    if (attributes == null) {
        return null;
    }
    for (AnnotationAttributes raw : attributes) {
        for (Map.Entry<String, Object> entry : AnnotationReadingVisitorUtils.convertClassValues("class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString).entrySet()) {
            allAttributes.add(entry.getKey(), entry.getValue());
        }
    }
    return allAttributes;
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) MultiValueMap(org.springframework.util.MultiValueMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap)

Example 12 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project dubbo by alibaba.

the class DubboConfigConfigurationSelector method selectImports.

@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableDubboConfig.class.getName()));
    boolean multiple = attributes.getBoolean("multiple");
    if (multiple) {
        return of(DubboConfigConfiguration.Multiple.class.getName());
    } else {
        return of(DubboConfigConfiguration.Single.class.getName());
    }
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 13 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryConfigurationExtension method postProcess.

@Override
public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) {
    AnnotationAttributes attributes = config.getAttributes();
    builder.addPropertyReference("spannerOperations", attributes.getString("spannerOperationsRef"));
    builder.addPropertyReference("spannerMappingContext", attributes.getString("spannerMappingContextRef"));
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 14 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-cloud-netflix by spring-cloud.

the class RibbonClientConfigurationRegistrar method registerBeanDefinitions.

@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
    Map<String, Object> attrs = metadata.getAnnotationAttributes(RibbonClients.class.getName(), true);
    if (attrs != null && attrs.containsKey("value")) {
        AnnotationAttributes[] clients = (AnnotationAttributes[]) attrs.get("value");
        for (AnnotationAttributes client : clients) {
            registerClientConfiguration(registry, getClientName(client), client.get("configuration"));
        }
    }
    if (attrs != null && attrs.containsKey("defaultConfiguration")) {
        String name;
        if (metadata.hasEnclosingClass()) {
            name = "default." + metadata.getEnclosingClassName();
        } else {
            name = "default." + metadata.getClassName();
        }
        registerClientConfiguration(registry, name, attrs.get("defaultConfiguration"));
    }
    Map<String, Object> client = metadata.getAnnotationAttributes(RibbonClient.class.getName(), true);
    String name = getClientName(client);
    if (name != null) {
        registerClientConfiguration(registry, name, client.get("configuration"));
    }
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 15 with AnnotationAttributes

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

the class KeyValueRepositoryConfigurationExtension method getQueryCreatorType.

/**
 * Detects the query creator type to be used for the factory to set. Will lookup a {@link QueryCreatorType} annotation
 * on the {@code @Enable}-annotation or use {@link SpelQueryCreator} if not found.
 *
 * @param config must not be {@literal null}.
 * @return
 */
private static Class<?> getQueryCreatorType(AnnotationRepositoryConfigurationSource config) {
    AnnotationMetadata metadata = config.getEnableAnnotationMetadata();
    Map<String, Object> queryCreatorAnnotationAttributes = metadata.getAnnotationAttributes(QueryCreatorType.class.getName());
    if (CollectionUtils.isEmpty(queryCreatorAnnotationAttributes)) {
        return SpelQueryCreator.class;
    }
    AnnotationAttributes queryCreatorAttributes = new AnnotationAttributes(queryCreatorAnnotationAttributes);
    return queryCreatorAttributes.getClass("value");
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) SpelQueryCreator(org.springframework.data.keyvalue.repository.query.SpelQueryCreator) AnnotationMetadata(org.springframework.core.type.AnnotationMetadata)

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