Example usage for org.springframework.context ApplicationContext getBeanNamesForAnnotation

List of usage examples for org.springframework.context ApplicationContext getBeanNamesForAnnotation

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContext getBeanNamesForAnnotation.

Prototype

String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType);

Source Link

Document

Find all names of beans which are annotated with the supplied Annotation type, without creating corresponding bean instances yet.

Usage

From source file:com.capgemini.boot.core.factory.internal.DefaultAnnotationStrategy.java

@Override
public String[] getFactoryBeanNames(ApplicationContext context) {
    return context.getBeanNamesForAnnotation(getFactoryClassAnnotation());
}

From source file:org.fenixedu.bennu.spring.BennuSpringConfiguration.java

private Set<String> getBaseNames(ApplicationContext context) {
    final Set<String> baseNames = new HashSet<>();
    baseNames.add(getBundleBasename("BennuSpringResources"));
    final String[] beanNames = context.getBeanNamesForAnnotation(BennuSpringModule.class);
    for (String beanName : beanNames) {
        BennuSpringModule bennuSpringModuleAnnotation = context.findAnnotationOnBean(beanName,
                BennuSpringModule.class);
        if (bennuSpringModuleAnnotation != null) {
            baseNames.addAll(Arrays.stream(bennuSpringModuleAnnotation.bundles()).map(this::getBundleBasename)
                    .collect(Collectors.toSet()));
        }//from  ww w  .  j av a2  s  . c  o m
    }
    return baseNames;
}