Example usage for org.springframework.core.type StandardMethodMetadata isAnnotated

List of usage examples for org.springframework.core.type StandardMethodMetadata isAnnotated

Introduction

In this page you can find the example usage for org.springframework.core.type StandardMethodMetadata isAnnotated.

Prototype

default boolean isAnnotated(String annotationName) 

Source Link

Document

Determine whether the underlying element has an annotation or meta-annotation of the given type defined.

Usage

From source file:com.quancheng.saluki.boot.runner.GrpcServiceRunner.java

private Collection<Object> getTypedBeansWithAnnotation(Class<? extends Annotation> annotationType)
        throws Exception {
    return Stream.of(applicationContext.getBeanNamesForAnnotation(annotationType)).filter(name -> {
        BeanDefinition beanDefinition = applicationContext.getBeanFactory().getBeanDefinition(name);
        if (beanDefinition.getSource() instanceof StandardMethodMetadata) {
            StandardMethodMetadata metadata = (StandardMethodMetadata) beanDefinition.getSource();
            return metadata.isAnnotated(annotationType.getName());
        }/*from   w  ww .j  a va 2 s .  c om*/
        return null != applicationContext.getBeanFactory().findAnnotationOnBean(name, annotationType);
    }).map(name -> applicationContext.getBeanFactory().getBean(name)).collect(Collectors.toList());

}