All I wanted to know was "all classes / methods in Spring beans that are annotated as @Versioned".
I created my annotation as
@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Versioned { ..... }
This annotation works fine when I use Java reflection to search for methods like:
for(Method m: obj.getClass().getMethods()){ if(m.isAnnotationPresent(Versioned.class)){ ....
But this does not work when I turn to Spring beans and try a similar check:
public class VersionScanner implements ApplicationContextAware{ public void setApplicationContext(ApplicationContext applicationContext){ for(String beanName: applicationContext.getBeanDefinitionNames()){ for(Method m: applicationContext.getBean(beanName).getClass().getDeclaredMethods()){ if(m.isAnnotationPresent(Versioned.class){
In fact, this code finds other annotations like @RequestMapping. I'm not sure what I am doing wrong with my custom annotation.
java spring spring-mvc
kamoor
source share