Project

General

Profile

1
package eu.dnetlib.metrics;
2

    
3
import java.util.List;
4

    
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.context.annotation.Configuration;
7
import org.springframework.web.servlet.HandlerInterceptor;
8
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
9
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
10

    
11
@Configuration
12
public class WebMvcConfig implements WebMvcConfigurer {
13

    
14
	@Autowired
15
	private List<MetricInterceptor> interceptors;
16

    
17
	@Override
18
	public void addInterceptors(InterceptorRegistry registry) {
19
		interceptors.stream()
20
				.filter(metricInterceptor -> metricInterceptor instanceof HandlerInterceptor)
21
				.map(metricInterceptor -> (HandlerInterceptor) metricInterceptor)
22
				.forEach(handlerInterceptor -> registry.addInterceptor(handlerInterceptor));
23
	}
24

    
25
}
(4-4/4)