Java 类org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping 实例源码

项目:spring4-understanding    文件:MvcUriComponentsBuilder.java   
/**
 * An alternative to {@link #fromMappingName(String)} that accepts a
 * {@code UriComponentsBuilder} representing the base URL. This is useful
 * when using MvcUriComponentsBuilder outside the context of processing a
 * request or to apply a custom baseUrl not matching the current request.
 * @param builder the builder for the base URL; the builder will be cloned
 * and therefore not modified and may be re-used for further calls.
 * @param name the mapping name
 * @return a builder to to prepare the URI String
 * @throws IllegalArgumentException if the mapping name is not found or
 * if there is no unique match
 * @since 4.2
 */
public static MethodArgumentBuilder fromMappingName(UriComponentsBuilder builder, String name) {
    RequestMappingInfoHandlerMapping handlerMapping = getRequestMappingInfoHandlerMapping();
    List<HandlerMethod> handlerMethods = handlerMapping.getHandlerMethodsForMappingName(name);
    if (handlerMethods == null) {
        throw new IllegalArgumentException("Mapping mappingName not found: " + name);
    }
    if (handlerMethods.size() != 1) {
        throw new IllegalArgumentException("No unique match for mapping mappingName " +
                name + ": " + handlerMethods);
    }
    HandlerMethod handlerMethod = handlerMethods.get(0);
    Class<?> controllerType = handlerMethod.getBeanType();
    Method method = handlerMethod.getMethod();
    return new MethodArgumentBuilder(builder, controllerType, method);
}
项目:sdoc    文件:DocumentScanner.java   
private Function<? super RequestMappingInfoHandlerMapping, Iterable<Map.Entry<RequestMappingInfo, HandlerMethod>>> toMappingEntries() {
    return new Function<RequestMappingInfoHandlerMapping, Iterable<Map.Entry<RequestMappingInfo, HandlerMethod>>>() {
        @Override
        public Iterable<Map.Entry<RequestMappingInfo, HandlerMethod>> apply(
                RequestMappingInfoHandlerMapping input) {
            return input.getHandlerMethods().entrySet();
        }
    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void singleRequestMappingInfoHandlerMappingBean() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    RequestMappingInfoHandlerMapping mapping = this.applicationContext
            .getBean(RequestMappingInfoHandlerMapping.class);
    assertThat(mapping).isNotEqualTo(instanceOf(EndpointHandlerMapping.class));
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void singleRequestMappingInfoHandlerMappingBean() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    RequestMappingInfoHandlerMapping mapping = this.applicationContext
            .getBean(RequestMappingInfoHandlerMapping.class);
    assertThat(mapping).isNotEqualTo(instanceOf(EndpointHandlerMapping.class));
}
项目:contestparser    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void singleRequestMappingInfoHandlerMappingBean() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    RequestMappingInfoHandlerMapping mapping = this.applicationContext
            .getBean(RequestMappingInfoHandlerMapping.class);
    assertThat(mapping, not(instanceOf(EndpointHandlerMapping.class)));
}
项目:sdoc    文件:DocumentScanner.java   
@Autowired
public DocumentScanner(List<RequestMappingInfoHandlerMapping> handlerMappings) {
    this.handlerMappings = handlerMappings;
}