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;
9 import de.spring.example.annotation.CustomTransactional;
12 public class AnnotationsHandler implements ApplicationContextAware, InitializingBean {
13 private ApplicationContext applicationContext;
16 public void afterPropertiesSet() {
17 GenericBeanFactoryAccessor genericBeanFactoryAccessor = new GenericBeanFactoryAccessor(applicationContext);
19 final Map<String, Object> transactionalClass = genericBeanFactoryAccessor.getBeansWithAnnotation(CustomTransactional.class);
21 for (final Object myFoo : transactionalClass.values()) {
22 final Class<? extends Object> fooClass = myFoo.getClass();
23 final CustomTransactional annotation = fooClass.getAnnotation(CustomTransactional.class);
24 System.out.println("Found foo class: " + fooClass + ", with tags: ");
29 public void setApplicationContext(final ApplicationContext applicationContext)
30 throws BeansException {
31 this.applicationContext = applicationContext;