Creating a Spring ApplicationListener

written by juan on June 21st, 2006 @ 12:00 AM

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).

Comments are closed

Options:

Size

Colors