List of usage examples for org.springframework.beans.factory.config ConfigurableListableBeanFactory getBeansWithAnnotation
Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws BeansException;
From source file:org.github.aenygmatic.payroll.usecases.postprocessors.EnumMapGeneratingBeanPostProcessor.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Map<String, Object> beansWithAnnotation = beanFactory.getBeansWithAnnotation(annotationType()); for (Class<?> interfaceType : interfaceTypes()) { Map<E, Object> proxyMap = newEnumMap(); for (Object bean : beansWithAnnotation.values()) { if (interfaceType.isInstance(bean)) { addToMap(proxyMap, bean); }/* w ww. j a v a 2s .c om*/ } beanFactory.registerSingleton(generateName(interfaceType), proxyMap); } }
From source file:org.github.aenygmatic.payroll.domain.annotations.postprocessing.CustomEnumAnnotationPostProcessor.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException { Map<String, Object> map = configurableListableBeanFactory.getBeansWithAnnotation(annotationType()); for (Object bean : map.values()) { registerCustomBeans(configurableListableBeanFactory, bean); }//w w w. j a v a 2s.com }
From source file:com.rvantwisk.cnctools.IndexerAppConfiguration.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Map<String, Object> beansWithAnnotation = beanFactory.getBeansWithAnnotation(Task.class); Collection operations = beansWithAnnotation.values(); System.out.println("Registering the following operations:"); for (Object operation : operations) { AbstractTask op = (AbstractTask) operation; allOperations.add(op);/*from ww w .j a v a2s . c o m*/ System.out.println(op.getName()); } System.out.println("- done"); }
From source file:org.focusns.common.event.support.EventInterceptor.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { ////from w w w.j a va 2 s. c om Map<String, Object> beansMap = beanFactory.getBeansWithAnnotation(EventSubscriber.class); for (Map.Entry<String, Object> entry : beansMap.entrySet()) { String beanName = entry.getKey(); Object beanObject = entry.getValue(); Class<?> beanClass = beanObject.getClass(); // Method[] declearedMethods = beanClass.getDeclaredMethods(); for (Method declearedMethod : declearedMethods) { // Event event = AnnotationUtils.getAnnotation(declearedMethod, Event.class); if (event == null) { log.warn(String.format("Event Subscribe method %s must be annotated with @Event(\"xxx\")", declearedMethod)); } else { String eventKey = generateEventKey(event); eventMapping.put(eventKey, event); eventMethodMapping.put(eventKey, declearedMethod); eventSubscriberMapping.put(eventKey, beanName); } } } }