Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring 3.5 how to add HttpSessionEventPublisher to my boot configuration

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?

like image 825
Alexandr Avatar asked Jul 25 '14 12:07

Alexandr


1 Answers

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"/>
like image 145
Shrikant Havale Avatar answered Oct 18 '22 07:10

Shrikant Havale