Example usage for org.springframework.beans.factory BeanFactoryUtils beanNamesForAnnotationIncludingAncestors

List of usage examples for org.springframework.beans.factory BeanFactoryUtils beanNamesForAnnotationIncludingAncestors

Introduction

In this page you can find the example usage for org.springframework.beans.factory BeanFactoryUtils beanNamesForAnnotationIncludingAncestors.

Prototype

public static String[] beanNamesForAnnotationIncludingAncestors(ListableBeanFactory lbf,
        Class<? extends Annotation> annotationType) 

Source Link

Document

Get all bean names whose Class has the supplied Annotation type, including those defined in ancestor factories, without creating any bean instances yet.

Usage

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

private Map<Class<?>, DiscoveredEndpoint> getEndpoints(Class<T> operationType) {
    Map<Class<?>, DiscoveredEndpoint> endpoints = new LinkedHashMap<>();
    Map<String, DiscoveredEndpoint> endpointsById = new LinkedHashMap<>();
    String[] beanNames = BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors(this.applicationContext,
            Endpoint.class);
    for (String beanName : beanNames) {
        addEndpoint(endpoints, endpointsById, beanName);
    }//w  ww  .j av a2  s.co  m
    return endpoints;
}

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

private Map<Class<?>, DiscoveredExtension> getExtensions(Class<T> operationType,
        Map<Class<?>, DiscoveredEndpoint> endpoints) {
    Map<Class<?>, DiscoveredExtension> extensions = new LinkedHashMap<>();
    String[] beanNames = BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors(this.applicationContext,
            EndpointExtension.class);
    for (String beanName : beanNames) {
        addExtension(endpoints, extensions, beanName);
    }/*from ww  w.ja v a 2 s.com*/
    return extensions;
}