Creating a Spring ApplicationListener
Im using acegi and i wanted to log in the database the user's last login date. Acegi generates ApplicationListener events so it is easy.
The hard thing is realizing that any bean that implements ApplicationListener can't have a constructor or properties, and must implement ApplicationContextAware to be able to get it dependencies during #onEvent. Why? The applications listeneres are created using ListableBeanFactory#getBeansOfType(ApplicationListener.class, true, false).
0 comments