Example usage for org.springframework.data.rest.webmvc RepositoryRestHandlerAdapter setMessageConverters

List of usage examples for org.springframework.data.rest.webmvc RepositoryRestHandlerAdapter setMessageConverters

Introduction

In this page you can find the example usage for org.springframework.data.rest.webmvc RepositoryRestHandlerAdapter setMessageConverters.

Prototype

public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters) 

Source Link

Document

Provide the converters to use in argument resolvers and return value handlers that support reading and/or writing to the body of the request and response.

Usage

From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.java

/**
 * Special {@link org.springframework.web.servlet.HandlerAdapter} that only recognizes handler methods defined in the
 * provided controller classes./*from w  ww.  java  2  s.c o  m*/
 * 
 * @param resourceProcessors {@link ResourceProcessor}s available in the {@link ApplicationContext}.
 * @return
 */
@Bean
public RequestMappingHandlerAdapter repositoryExporterHandlerAdapter() {

    // Forward conversion service to handler adapter
    ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
    initializer.setConversionService(defaultConversionService());

    RepositoryRestHandlerAdapter handlerAdapter = new RepositoryRestHandlerAdapter(
            defaultMethodArgumentResolvers(), resourceProcessorInvoker());
    handlerAdapter.setWebBindingInitializer(initializer);
    handlerAdapter.setMessageConverters(defaultMessageConverters());

    if (config().getMetadataConfiguration().alpsEnabled()) {
        handlerAdapter
                .setResponseBodyAdvice(Arrays.<ResponseBodyAdvice<?>>asList(alpsJsonHttpMessageConverter()));
    }

    return handlerAdapter;
}