From 1e9efcd606c678d4ad865c1b71131fd08ff8b6a0 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Sat, 23 Feb 2019 17:40:40 -0300 Subject: [PATCH] Added scenario using FooPageableLiveTest bean --- .../java/com/baeldung/spring/WebConfig.java | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java index d5559bfae7..4b876a8338 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java @@ -2,6 +2,7 @@ package com.baeldung.spring; import java.util.List; +import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @@ -35,26 +36,34 @@ public class WebConfig implements WebMvcConfigurer { // } // Another possibility is to create a bean which will be automatically added to the Spring Boot Autoconfigurations -// @Bean -// public HttpMessageConverter createXmlHttpMessageConverter() { -// final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter(); -// -// final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller(); -// xstreamMarshaller.setAutodetectAnnotations(true); -// xmlConverter.setMarshaller(xstreamMarshaller); -// xmlConverter.setUnmarshaller(xstreamMarshaller); -// -// return xmlConverter; -// } - - + // @Bean + // public HttpMessageConverter createXmlHttpMessageConverter() { + // final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter(); + // + // final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller(); + // xstreamMarshaller.setAutodetectAnnotations(true); + // xmlConverter.setMarshaller(xstreamMarshaller); + // xmlConverter.setUnmarshaller(xstreamMarshaller); + // + // return xmlConverter; + // } + // Etags - + // If we're not using Spring Boot we can make use of // AbstractAnnotationConfigDispatcherServletInitializer#getServletFilters @Bean - public ShallowEtagHeaderFilter shallowEtagHeaderFilter() { - return new ShallowEtagHeaderFilter(); + public FilterRegistrationBean shallowEtagHeaderFilter() { + FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>( new ShallowEtagHeaderFilter()); + filterRegistrationBean.addUrlPatterns("/auth/foos/*"); + filterRegistrationBean.setName("etagFilter"); + return filterRegistrationBean; } + + // We can also just declare the filter directly + // @Bean + // public ShallowEtagHeaderFilter shallowEtagHeaderFilter() { + // return new ShallowEtagHeaderFilter(); + // } } \ No newline at end of file