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

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

Introduction

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

Prototype

public void setResponseBodyAdvice(@Nullable List<ResponseBodyAdvice<?>> responseBodyAdvice) 

Source Link

Document

Add one or more ResponseBodyAdvice instances to intercept the response before @ResponseBody or ResponseEntity return values are written to the response body.

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 ww  w. j  a  v  a  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;
}