Search in sources :

Example 21 with RequestMappingHandlerAdapter

use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter in project dhis2-core by dhis2.

the class MessageConverterAddingPostProcessor method postProcessAfterInitialization.

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (!(bean instanceof RequestMappingHandlerAdapter)) {
        return bean;
    }
    RequestMappingHandlerAdapter handlerAdapter = (RequestMappingHandlerAdapter) bean;
    List<HttpMessageConverter<?>> converters = handlerAdapter.getMessageConverters();
    converters.add(0, messageConverter);
    handlerAdapter.setMessageConverters(converters);
    return handlerAdapter;
}
Also used : HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) RequestMappingHandlerAdapter(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)

Aggregations

RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)21 Test (org.junit.Test)17 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)6 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)5 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)4 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)4 ConfigurableWebBindingInitializer (org.springframework.web.bind.support.ConfigurableWebBindingInitializer)4 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)4 RequestMappingHandlerMapping (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ConversionService (org.springframework.core.convert.ConversionService)3 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)3 HandlerExecutionChain (org.springframework.web.servlet.HandlerExecutionChain)3 ConversionServiceExposingInterceptor (org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor)3 List (java.util.List)2 ApplicationContext (org.springframework.context.ApplicationContext)2 Bean (org.springframework.context.annotation.Bean)2 FormattingConversionService (org.springframework.format.support.FormattingConversionService)2 ContentNegotiationManager (org.springframework.web.accept.ContentNegotiationManager)2 HandlerExceptionResolverComposite (org.springframework.web.servlet.handler.HandlerExceptionResolverComposite)2