Package org.springframework.web.method

Examples of org.springframework.web.method.HandlerMethod


    when(mappings.exportsTopLevelResourceFor("people")).thenReturn(true);
    mockRequest = new MockHttpServletRequest("GET", "/base");

    configuration.setBaseUri(URI.create("base"));

    HandlerMethod method = handlerMapping.lookupHandlerMethod("/base", mockRequest);

    assertThat(method, is(notNullValue()));
    assertThat(method.getMethod(), is(rootHandlerMethod));
  }
View Full Code Here


    when(mappings.exportsTopLevelResourceFor("people")).thenReturn(true);
    mockRequest = new MockHttpServletRequest("GET", baseUri.concat("/people/"));

    configuration.setBaseUri(URI.create(baseUri));

    HandlerMethod method = handlerMapping.lookupHandlerMethod("/base/people/", mockRequest);

    assertThat(method, is(notNullValue()));
    assertThat(method.getMethod(), is(listEntitiesMethod));
  }
View Full Code Here

    mockRequest = new MockHttpServletRequest("GET", uri);
    mockRequest.setServletPath(uri);

    configuration.setBaseUri(URI.create(baseUri));

    HandlerMethod method = handlerMapping.lookupHandlerMethod("/base/people/", mockRequest);

    assertThat(method, is(notNullValue()));
    assertThat(method.getMethod(), is(listEntitiesMethod));
  }
View Full Code Here

    mockRequest = new MockHttpServletRequest("GET", uri);
    mockRequest.setServletPath(uri);

    configuration.setBaseUri(URI.create(baseUri));

    HandlerMethod method = handlerMapping.lookupHandlerMethod("/people", mockRequest);

    assertThat(method, is(nullValue()));
  }
View Full Code Here

    mockRequest = new MockHttpServletRequest("GET", uri);
    mockRequest.setServletPath(uri);

    configuration.setBaseUri(URI.create(baseUri));

    HandlerMethod method = handlerMapping.lookupHandlerMethod("/people", mockRequest);

    assertThat(method, is(nullValue()));
  }
View Full Code Here

            @Override
            public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                                   ModelAndView modelAndView) throws Exception {

                if (handler instanceof HandlerMethod) {
                    HandlerMethod handlerMethod = (HandlerMethod) handler;
                    Navigation navSection = handlerMethod.getBean().getClass().getAnnotation(Navigation.class);
                    if (navSection != null && modelAndView != null) {
                        modelAndView.addObject("navSection", navSection.value().toString().toLowerCase());
                    }
                }
            }
View Full Code Here

    return name;
  }

  public static String getRequestNameFromHandler(HandlerExecutionChain handler) {
    if (handler != null && handler.getHandler() instanceof HandlerMethod) {
      HandlerMethod handlerMethod = (HandlerMethod) handler.getHandler();
      return StringUtils.splitCamelCase(StringUtils.capitalize(handlerMethod.getMethod().getName()));
    }
    return "";
  }
View Full Code Here

  private HandlerMapping createHandlerMapping(MockHttpServletRequest request, Method requestMappingMethod) throws Exception {
    System.out.println("createHandlerMapping"+request);
    HandlerMapping requestMappingHandlerMapping = mock(HandlerMapping.class);
    HandlerExecutionChain handlerExecutionChain = mock(HandlerExecutionChain.class);
    HandlerMethod handlerMethod = mock(HandlerMethod.class);

    when(handlerMethod.getMethod()).thenReturn(requestMappingMethod);
    when(handlerExecutionChain.getHandler()).thenReturn(handlerMethod);
    when(requestMappingHandlerMapping.getHandler(Matchers.argThat(new Matcher<HttpServletRequest>() {
      @Override
      public boolean matches(Object item) {
        return ((HttpServletRequest) item).getRequestURI().equals("/test/requestName");
View Full Code Here

   * @param mapping the mapping conditions associated with the handler method
   * @throws IllegalStateException if another method was already registered
   * under the same mapping
   */
  protected void registerHandlerMethod(Object handler, Method method, T mapping) {
    HandlerMethod newHandlerMethod = createHandlerMethod(handler, method);
    HandlerMethod oldHandlerMethod = this.handlerMethods.get(mapping);
    if (oldHandlerMethod != null && !oldHandlerMethod.equals(newHandlerMethod)) {
      throw new IllegalStateException("Ambiguous mapping found. Cannot map '" + newHandlerMethod.getBean() +
          "' bean method \n" + newHandlerMethod + "\nto " + mapping + ": There is already '" +
          oldHandlerMethod.getBean() + "' bean method\n" + oldHandlerMethod + " mapped.");
    }

    this.handlerMethods.put(mapping, newHandlerMethod);
    if (logger.isInfoEnabled()) {
      logger.info("Mapped \"" + mapping + "\" onto " + newHandlerMethod);
View Full Code Here

   * @param handler either a bean name or an actual handler instance
   * @param method the target method
   * @return the created HandlerMethod
   */
  protected HandlerMethod createHandlerMethod(Object handler, Method method) {
    HandlerMethod handlerMethod;
    if (handler instanceof String) {
      String beanName = (String) handler;
      handlerMethod = new HandlerMethod(beanName, getApplicationContext(), method);
    }
    else {
      handlerMethod = new HandlerMethod(handler, method);
    }
    return handlerMethod;
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.method.HandlerMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.