Example usage for org.springframework.data.rest.webmvc BasePathAwareHandlerMapping BasePathAwareHandlerMapping

List of usage examples for org.springframework.data.rest.webmvc BasePathAwareHandlerMapping BasePathAwareHandlerMapping

Introduction

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

Prototype

public BasePathAwareHandlerMapping(RepositoryRestConfiguration configuration) 

Source Link

Document

Creates a new BasePathAwareHandlerMapping using the given RepositoryRestConfiguration .

Usage

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

/**
 * The {@link HandlerMapping} to delegate requests to Spring Data REST controllers. Sets up a
 * {@link DelegatingHandlerMapping} to make sure manually implemented {@link BasePathAwareController} instances that
 * register custom handlers for certain media types don't cause the {@link RepositoryRestHandlerMapping} to be
 * omitted./*from   w w  w.j a v a 2  s .co m*/
 * 
 * @see DATAREST-490
 * @return
 */
@Bean
public DelegatingHandlerMapping restHandlerMapping() {

    RepositoryRestHandlerMapping repositoryMapping = new RepositoryRestHandlerMapping(resourceMappings(),
            config());
    repositoryMapping.setJpaHelper(jpaHelper());
    repositoryMapping.setApplicationContext(applicationContext);
    repositoryMapping.afterPropertiesSet();

    BasePathAwareHandlerMapping basePathMapping = new BasePathAwareHandlerMapping(config());
    basePathMapping.setApplicationContext(applicationContext);
    basePathMapping.afterPropertiesSet();

    List<HandlerMapping> mappings = new ArrayList<HandlerMapping>();
    mappings.add(basePathMapping);
    mappings.add(repositoryMapping);

    return new DelegatingHandlerMapping(mappings);
}