Is there a "Spring 3 MVC" way to listen for a session end event?

I want to delete some temporary files when the user session ends. Information associated with files is stored in an object annotated with @SessionAttributes.

The only way I came across is to create HttpSessionListener.

Is there a higher level, simplified, Springy way to listen to the end of session event where I could easily get my annotated object?

+5
source share
3 answers

You will most likely need to create an HttpSessionListener.

Another stackoverflow answer:

Session Timeout Detection in Spring 3 / Spring Security 2.0.5

Also an example of how to load Spring beans into it:

http://www.mkyong.com/spring/spring-how-to-do-dependency-injection-in-your-session-listener/

+6

HttpSessionListener spring beans:

-, WebApplicationContextUtils.getRequiredApplicationContext(servletContext) . :

  • getBean(..)
  • @Autowired/@Inject, getAutowireCapablyBeanFactory().autowireBean(this). (, null), .

- AspectJ @Configurable .

+6

All Articles