Misfiring Neurons Just another geek with a blog

8Apr/09Off

Annotation-based dispatch for Spring ApplicationEvents

I created a little extension that allows you to dispatch Spring application context events in a clean and type-safe way to POJO beans. Instead of implementing the ApplicationListener interface, one can simply create a handler as follows:

public class EventListener {
    @EventHandler
    public void onAppEvent(MyCustomEvent event) {
        // ...
    }
}

Related Spring forum thread.

Update on 2011/05/07.

The code was moved to Github.

Please also see the Spring Custom Annotations project on Google Code.