Blame view

src/main/java/fr/plil/sio/web/mvc/ApplicationMvcConfiguration.java 1.3 KB
aa193b2b   Julien Iguchi-Cartigny   First version
1
2
  package fr.plil.sio.web.mvc;
  
8efec875   Julien Iguchi-Cartigny   switch to spring ...
3
  
5e965ce4   Julien Iguchi-Cartigny   working version
4
5
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
aa193b2b   Julien Iguchi-Cartigny   First version
6
  import org.springframework.context.annotation.Bean;
aa193b2b   Julien Iguchi-Cartigny   First version
7
8
9
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.Scope;
  import org.springframework.context.annotation.ScopedProxyMode;
5e965ce4   Julien Iguchi-Cartigny   working version
10
  import org.springframework.web.context.WebApplicationContext;
aa193b2b   Julien Iguchi-Cartigny   First version
11
  import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
5e965ce4   Julien Iguchi-Cartigny   working version
12
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
aa193b2b   Julien Iguchi-Cartigny   First version
13
  
aa193b2b   Julien Iguchi-Cartigny   First version
14
  @Configuration
0399d385   Julien Iguchi-Cartigny   Adding user form
15
  public class ApplicationMvcConfiguration extends WebMvcConfigurerAdapter {
5e965ce4   Julien Iguchi-Cartigny   working version
16
  
8efec875   Julien Iguchi-Cartigny   switch to spring ...
17
      private static final Logger logger = LoggerFactory.getLogger(ApplicationMvcConfiguration.class);
aa193b2b   Julien Iguchi-Cartigny   First version
18
19
  
      @Bean
5e965ce4   Julien Iguchi-Cartigny   working version
20
      @Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode. TARGET_CLASS)
aa193b2b   Julien Iguchi-Cartigny   First version
21
      public UserSession userSession() {
d938bbff   Julien Iguchi-Cartigny   add log message
22
          logger.debug("new user session bean");
aa193b2b   Julien Iguchi-Cartigny   First version
23
24
25
26
27
28
29
30
31
32
33
34
35
36
          return new UserSession();
      }
  
      @Bean
      public CheckUserInterceptor checkUserInterceptor() {
          return new CheckUserInterceptor();
      }
  
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
          CheckUserInterceptor interceptor = checkUserInterceptor();
          interceptor.setUserSession(userSession());
          registry.addInterceptor(interceptor);
      }
aa193b2b   Julien Iguchi-Cartigny   First version
37
  }