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

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

Introduction

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

Prototype

public RepositoryRestHandlerMapping(ResourceMappings mappings, RepositoryRestConfiguration config) 

Source Link

Document

Creates a new RepositoryRestHandlerMapping for the given ResourceMappings and 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  .ja v  a2 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);
}