Example usage for org.springframework.core.annotation AnnotatedElementUtils findMergedAnnotationAttributes

List of usage examples for org.springframework.core.annotation AnnotatedElementUtils findMergedAnnotationAttributes

Introduction

In this page you can find the example usage for org.springframework.core.annotation AnnotatedElementUtils findMergedAnnotationAttributes.

Prototype

@Nullable
public static AnnotationAttributes findMergedAnnotationAttributes(AnnotatedElement element,
        String annotationName, boolean classValuesAsString, boolean nestedAnnotationsAsMap) 

Source Link

Document

Find the first annotation of the specified annotationName within the annotation hierarchy above the supplied element and merge that annotation's attributes with matching attributes from annotations in lower levels of the annotation hierarchy.

Usage

From source file:org.springframework.boot.actuate.endpoint.annotation.AnnotationEndpointDiscoverer.java

private DiscoveredEndpoint createEndpoint(Object target, Class<?> endpointType) {
    AnnotationAttributes annotationAttributes = AnnotatedElementUtils
            .findMergedAnnotationAttributes(endpointType, Endpoint.class, true, true);
    String id = annotationAttributes.getString("id");
    Assert.state(StringUtils.hasText(id), "No @Endpoint id attribute specified for " + endpointType.getName());
    boolean enabledByDefault = (Boolean) annotationAttributes.get("enableByDefault");
    Collection<T> operations = this.operationsFactory.createOperations(id, target, endpointType).values();
    EndpointInfo<T> endpointInfo = new EndpointInfo<>(id, enabledByDefault, operations);
    boolean exposed = isEndpointExposed(endpointType, endpointInfo);
    return new DiscoveredEndpoint(endpointType, endpointInfo, exposed);
}

From source file:org.springframework.test.context.BootstrapUtils.java

private static Class<?> resolveDefaultTestContextBootstrapper(Class<?> testClass) throws Exception {
    ClassLoader classLoader = BootstrapUtils.class.getClassLoader();
    AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(testClass,
            WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME, false, false);
    if (attributes != null) {
        return ClassUtils.forName(DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, classLoader);
    }//from   w  ww.j  av a2s  .  c  o  m
    return ClassUtils.forName(DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, classLoader);
}