Example usage for org.springframework.boot.context.properties ConfigurationBeanFactoryMetadata findFactoryAnnotation

List of usage examples for org.springframework.boot.context.properties ConfigurationBeanFactoryMetadata findFactoryAnnotation

Introduction

In this page you can find the example usage for org.springframework.boot.context.properties ConfigurationBeanFactoryMetadata findFactoryAnnotation.

Prototype

public <A extends Annotation> A findFactoryAnnotation(String beanName, Class<A> type) 

Source Link

Usage

From source file:org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.java

/**
 * Extract configuration prefix from {@link ConfigurationProperties} annotation.
 * @param context the application context
 * @param beanFactoryMetaData the bean factory meta-data
 * @param beanName the bean name/* ww  w. ja  va2 s  . c  om*/
 * @return the prefix
 */
private String extractPrefix(ApplicationContext context, ConfigurationBeanFactoryMetadata beanFactoryMetaData,
        String beanName) {
    ConfigurationProperties annotation = context.findAnnotationOnBean(beanName, ConfigurationProperties.class);
    if (beanFactoryMetaData != null) {
        ConfigurationProperties override = beanFactoryMetaData.findFactoryAnnotation(beanName,
                ConfigurationProperties.class);
        if (override != null) {
            // The @Bean-level @ConfigurationProperties overrides the one at type
            // level when binding. Arguably we should render them both, but this one
            // might be the most relevant for a starting point.
            annotation = override;
        }
    }
    return annotation.prefix();
}