Jesper de Jong wrote:What Tushar posted probably works, but it looks more complicated than necessary. The Spring ApplicationContext has a method to do exactly what you want: getBeansWithAnnotation.
It returns a Map in which the keys are bean names and the values are bean instances.
For example:
Thanks a bunch, I have a follow up question , We also have CommandHandlers which handles particular Command.
I would like to annotate method in class as follows
There is another class Router which will route Command to its handler and invoke handle method.
Class Router is as follows
}
I want Spring to populate above map automatically when Spring Context is loaded. How to achieve this , given now I know how to find classes with @Command Annotations.