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

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

Introduction

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

Prototype

@Nullable
public static AnnotationAttributes getMergedAnnotationAttributes(AnnotatedElement element,
        String annotationName) 

Source Link

Document

Get 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.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.java

@Nullable
private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
    if (ao.getAnnotations().length > 0) {
        for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
            AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(ao, type);
            if (attributes != null) {
                return attributes;
            }/*from  w ww  .ja  v  a2s . c  om*/
        }
    }
    return null;
}

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

private Class<?> getEndpointType(Class<?> extensionType) {
    AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(extensionType,
            EndpointExtension.class);
    Class<?> endpointType = attributes.getClass("endpoint");
    Assert.state(!endpointType.equals(Void.class),
            () -> "Extension " + endpointType.getName() + " does not specify an endpoint");
    return endpointType;
}

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

private boolean isEndpointExposed(Class<?> endpointType, EndpointInfo<T> endpointInfo) {
    if (isEndpointFiltered(endpointInfo)) {
        return false;
    }//from www.  j a v a2 s. co m
    AnnotationAttributes annotationAttributes = AnnotatedElementUtils
            .getMergedAnnotationAttributes(endpointType, FilteredEndpoint.class);
    if (annotationAttributes == null) {
        return true;
    }
    Class<?> filterClass = annotationAttributes.getClass("value");
    return isFilterMatch(filterClass, endpointInfo);
}

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

/**
 * Determines if an extension is exposed.
 * @param endpointType the endpoint type
 * @param extensionType the extension type
 * @param endpointInfo the endpoint info
 * @return if the extension is exposed/*from  w ww.ja va  2 s . c o m*/
 */
protected boolean isExtensionExposed(Class<?> endpointType, Class<?> extensionType,
        EndpointInfo<T> endpointInfo) {
    AnnotationAttributes annotationAttributes = AnnotatedElementUtils
            .getMergedAnnotationAttributes(extensionType, EndpointExtension.class);
    Class<?> filterClass = annotationAttributes.getClass("filter");
    return isFilterMatch(filterClass, endpointInfo);
}