Annotation Interface EnableSpringHttpSession


@Retention(RUNTIME) @Target(TYPE) @Documented @Import(SpringHttpSessionConfiguration.class) public @interface EnableSpringHttpSession
Add this annotation to an @Configuration class to expose the SessionRepositoryFilter as a bean named "springSessionRepositoryFilter" and backed by a user provided implementation of SessionRepository. In order to leverage the annotation, a single SessionRepository bean must be provided. For example:
 
 @Configuration(proxyBeanMethods = false)
 @EnableSpringHttpSession
 public class SpringHttpSessionConfig {

     @Bean
     public MapSessionRepository sessionRepository() {
         return new MapSessionRepository(new ConcurrentHashMap<>());
     }

 }
  

It is important to note that no infrastructure for session expirations is configured for you out of the box. This is because things like session expiration are highly implementation dependent. This means if you require cleaning up expired sessions, you are responsible for cleaning up the expired sessions.

The following is provided for you with the base configuration:

  • SessionRepositoryFilter - is responsible for wrapping the HttpServletRequest with an implementation of HttpSession that is backed by a SessionRepository
  • SessionEventHttpSessionListenerAdapter - is responsible for translating Spring Session events into HttpSessionEvent. In order for it to work, the implementation of SessionRepository you provide must support SessionCreatedEvent and SessionDestroyedEvent.
Since:
1.1