mardi 20 mars 2018

Spring Boot - Get all methods with custom annotation

I have a custom annotation:

@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
annotation class Listener

Used like this:

@Service
class MyService {

   @Listener
   fun onNewThing(thing: Thing) {
       ...
   }
}

In another service, every time something happen, I want to call each function annotated with @Listener and with a parameter of type Thing. How can I do it without looping through all the beans in the context and checking all the methods?





Aucun commentaire:

Enregistrer un commentaire