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

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

Introduction

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

Prototype

public void setWebBindingInitializer(@Nullable WebBindingInitializer webBindingInitializer) 

Source Link

Document

Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.

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./*  www.ja va  2 s  .  co 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;
}