ApplicationMvcConfiguration.java
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package fr.plil.sio.web.mvc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
public class ApplicationMvcConfiguration extends WebMvcConfigurerAdapter {
private static final Logger logger = LoggerFactory.getLogger(ApplicationMvcConfiguration.class);
@Bean
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode. TARGET_CLASS)
public UserSession userSession() {
logger.debug("new user session bean");
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);
}
}