1 package de.spring.example;
4 import org.springframework.beans.BeansException;
5 import org.springframework.beans.factory.InitializingBean;
6 import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor;
7 import org.springframework.context.ApplicationContext;
8 import org.springframework.context.ApplicationContextAware;
11 public class AnnotationsHandler implements ApplicationContextAware, InitializingBean {
12 private ApplicationContext applicationContext;
15 public void afterPropertiesSet() {
16 GenericBeanFactoryAccessor genericBeanFactoryAccessor = new GenericBeanFactoryAccessor(applicationContext);
18 final Map<String, Object> transactionalClass = genericBeanFactoryAccessor.getBeansWithAnnotation(TransactionalN2A.class);
20 for (final Object myFoo : transactionalClass.values()) {
21 final Class<? extends Object> fooClass = myFoo.getClass();
22 final TransactionalN2A annotation = fooClass.getAnnotation(TransactionalN2A.class);
23 System.out.println("Found 1 foo class: " + fooClass + ", with tags: ");
28 public void setApplicationContext(final ApplicationContext applicationContext)
29 throws BeansException {
30 this.applicationContext = applicationContext;