Example usage for org.springframework.core.type AnnotationMetadata getAllAnnotationAttributes

List of usage examples for org.springframework.core.type AnnotationMetadata getAllAnnotationAttributes

Introduction

In this page you can find the example usage for org.springframework.core.type AnnotationMetadata getAllAnnotationAttributes.

Prototype

@Nullable
default MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName) 

Source Link

Document

Retrieve all attributes of all annotations of the given type, if any (i.e.

Usage

From source file:de.codecentric.capturereplay.annotation.CaptureReplayImportBeanDefinitionRegistrar.java

@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
        BeanDefinitionRegistry registry) {
    MultiValueMap<String, Object> attributes = importingClassMetadata
            .getAllAnnotationAttributes(EnableCaptureReplay.class.getName());

    Mode mode = Mode.valueOf(attributes.getFirst("mode").toString());

    if (!Mode.OFF.equals(mode)) {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(CaptureReplayAdvice.class);
        builder.addPropertyValue("mode", mode);
        builder.addPropertyReference("dataMapper", attributes.getFirst("dataMapper").toString());
        registry.registerBeanDefinition(DEFAULT_CAPTURE_REPLAY_ADVICE_BEAN_ID, builder.getBeanDefinition());

        AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry);
    }// w  ww .j  ava2 s.  c om
}

From source file:cf.spring.servicebroker.ServiceBrokerConfiguration.java

@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    final MultiValueMap<String, Object> annotationAttributes = importMetadata
            .getAllAnnotationAttributes(EnableServiceBroker.class.getName());
    final String username = evaluate(annotationAttributes.getFirst("username").toString());
    final String password = evaluate(annotationAttributes.getFirst("password").toString());
    if (username == null) {
        throw new IllegalArgumentException("username cannot be null");
    }/*from   w  ww.  j a v  a2  s  .c  o  m*/
    if (password == null) {
        throw new IllegalArgumentException("password cannot be null");
    }
    authenticator = new HttpBasicAuthenticator("", username, password);
}

From source file:cf.spring.CfComponentConfiguration.java

@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    final MultiValueMap<String, Object> attributes = importMetadata
            .getAllAnnotationAttributes(CfComponent.class.getName());
    type = evaluate(attributes, "type");
    index = Integer.valueOf(evaluate(attributes, "index"));
    uuid = evaluate(attributes, "uuid");
    if (StringUtils.isEmpty(uuid)) {
        uuid = UUID.randomUUID().toString();
    }/*from   ww  w .  ja v a 2 s .c  o  m*/
    host = evaluate(attributes, "host");
    port = Integer.valueOf(evaluate(attributes, "port"));
    username = evaluate(attributes, "username");
    password = evaluate(attributes, "password");
    if (StringUtils.isEmpty(password)) {
        password = new BigInteger(256, ThreadLocalRandom.current()).toString(32);
    }
}

From source file:org.springframework.integration.config.MessagingGatewayRegistrar.java

/**
 * TODO until SPR-11710 will be resolved.
 * Captures the meta-annotation attribute values, in order.
 * @param importingClassMetadata The importing class metadata
 * @return The captured values.//  w w  w.j  a  v  a  2 s  .c  o m
 */
private List<MultiValueMap<String, Object>> captureMetaAnnotationValues(
        AnnotationMetadata importingClassMetadata) {
    Set<String> directAnnotations = importingClassMetadata.getAnnotationTypes();
    List<MultiValueMap<String, Object>> valuesHierarchy = new ArrayList<MultiValueMap<String, Object>>();
    // Need to grab the values now; see SPR-11710
    for (String ann : directAnnotations) {
        Set<String> chain = importingClassMetadata.getMetaAnnotationTypes(ann);
        if (chain.contains(MessagingGateway.class.getName())) {
            for (String meta : chain) {
                valuesHierarchy.add(importingClassMetadata.getAllAnnotationAttributes(meta));
            }
        }
    }
    return valuesHierarchy;
}