I want to listen to session life cycle events. I read about adding
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
to web.xml. But I don't have it. I am using class that extends SpringBootServletInitializer. How I can add this listener?
Just to provide reference to official documentation, http://docs.spring.io/spring-session/docs/current-SNAPSHOT/reference/html5/#httpsession-rest
Here if you refer to, HttpSessionListener
topic, you will find the clear example of doing it both Java
and XML
configuration way.
if your configuration support Redis
@Configuration
@EnableRedisHttpSession
public class RedisHttpSessionConfig {
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
// ...
}
In XML configuration, this might look like
<bean class="org.springframework.security.web.session.HttpSessionEventPublisher"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With