use of org.springframework.web.servlet.mvc.method.annotation.JsonViewRequestBodyAdvice in project spring-framework by spring-projects.
the class WebMvcConfigurationSupport method requestMappingHandlerAdapter.
/**
* Returns a {@link RequestMappingHandlerAdapter} for processing requests
* through annotated controller methods. Consider overriding one of these
* other more fine-grained methods:
* <ul>
* <li>{@link #addArgumentResolvers} for adding custom argument resolvers.
* <li>{@link #addReturnValueHandlers} for adding custom return value handlers.
* <li>{@link #configureMessageConverters} for adding custom message converters.
* </ul>
*/
@Bean
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
RequestMappingHandlerAdapter adapter = createRequestMappingHandlerAdapter();
adapter.setContentNegotiationManager(mvcContentNegotiationManager());
adapter.setMessageConverters(getMessageConverters());
adapter.setWebBindingInitializer(getConfigurableWebBindingInitializer());
adapter.setCustomArgumentResolvers(getArgumentResolvers());
adapter.setCustomReturnValueHandlers(getReturnValueHandlers());
if (jackson2Present) {
adapter.setRequestBodyAdvice(Collections.singletonList(new JsonViewRequestBodyAdvice()));
adapter.setResponseBodyAdvice(Collections.singletonList(new JsonViewResponseBodyAdvice()));
}
AsyncSupportConfigurer configurer = new AsyncSupportConfigurer();
configureAsyncSupport(configurer);
if (configurer.getTaskExecutor() != null) {
adapter.setTaskExecutor(configurer.getTaskExecutor());
}
if (configurer.getTimeout() != null) {
adapter.setAsyncRequestTimeout(configurer.getTimeout());
}
adapter.setCallableInterceptors(configurer.getCallableInterceptors());
adapter.setDeferredResultInterceptors(configurer.getDeferredResultInterceptors());
return adapter;
}
use of org.springframework.web.servlet.mvc.method.annotation.JsonViewRequestBodyAdvice in project spring-framework by spring-projects.
the class TestPathHelper method verifyRequestResponseBodyAdvice.
@SuppressWarnings("unchecked")
private void verifyRequestResponseBodyAdvice(Object bean) {
assertNotNull(bean);
Object value = new DirectFieldAccessor(bean).getPropertyValue("requestResponseBodyAdvice");
assertNotNull(value);
assertTrue(value instanceof List);
List<ResponseBodyAdvice> converters = (List<ResponseBodyAdvice>) value;
assertTrue(converters.get(0) instanceof JsonViewRequestBodyAdvice);
assertTrue(converters.get(1) instanceof JsonViewResponseBodyAdvice);
}
Aggregations