Package org.springframework.web.servlet

Examples of org.springframework.web.servlet.HandlerExecutionChain


    request.setContextPath("/springtravel");
    request.setServletPath("/app");
    request.setPathInfo("/foo/flow2");
    request.setRequestURI("/springtravel/app/foo/flow2");
    request.setMethod("GET");
    HandlerExecutionChain chain = mapping.getHandler(request);
    assertNotNull(chain);
    FlowHandler handler = (FlowHandler) chain.getHandler();
    assertEquals("foo/flow2", handler.getFlowId());
    assertTrue(handler instanceof CustomFlowHandler);
  }
View Full Code Here


    request.setContextPath("/springtravel");
    request.setServletPath("/app");
    request.setPathInfo("/bogus");
    request.setRequestURI("/springtravel/app/bogus");
    request.setMethod("GET");
    HandlerExecutionChain chain = mapping.getHandler(request);
    assertNull(chain);
  }
View Full Code Here

   * @param request current HTTP request
   * @return the HandlerExecutionChain (never <code>null</code>)
   * @see #getAdaptedInterceptors()
   */
  protected HandlerExecutionChain getHandlerExecutionChain(Object handler, HttpServletRequest request) {
    HandlerExecutionChain chain =
      (handler instanceof HandlerExecutionChain) ?
        (HandlerExecutionChain) handler : new HandlerExecutionChain(handler);
       
    chain.addInterceptors(getAdaptedInterceptors());
   
    String lookupPath = urlPathHelper.getLookupPathForRequest(request);
    for (MappedInterceptor mappedInterceptor : mappedInterceptors) {
      if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
        chain.addInterceptor(mappedInterceptor.getInterceptor());
      }
    }
   
    return chain;
  }
View Full Code Here

   * @return the final handler object
   */
  protected Object buildPathExposingHandler(Object rawHandler, String bestMatchingPattern,
      String pathWithinMapping, Map<String, String> uriTemplateVariables) {

    HandlerExecutionChain chain = new HandlerExecutionChain(rawHandler);
    chain.addInterceptor(new PathExposingHandlerInterceptor(bestMatchingPattern, pathWithinMapping));
    if (!CollectionUtils.isEmpty(uriTemplateVariables)) {
      chain.addInterceptor(new UriTemplateVariablesHandlerInterceptor(uriTemplateVariables));
    }
    return chain;
  }
View Full Code Here

   * @param request current HTTP request
   * @return the HandlerExecutionChain (never <code>null</code>)
   * @see #getAdaptedInterceptors()
   */
  protected HandlerExecutionChain getHandlerExecutionChain(Object handler, HttpServletRequest request) {
    HandlerExecutionChain chain =
      (handler instanceof HandlerExecutionChain) ?
        (HandlerExecutionChain) handler : new HandlerExecutionChain(handler);

    chain.addInterceptors(getAdaptedInterceptors());

    String lookupPath = urlPathHelper.getLookupPathForRequest(request);
    for (MappedInterceptor mappedInterceptor : mappedInterceptors) {
      if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
        chain.addInterceptor(mappedInterceptor.getInterceptor());
      }
    }

    return chain;
  }
View Full Code Here

   * @return the final handler object
   */
  protected Object buildPathExposingHandler(Object rawHandler, String bestMatchingPattern,
      String pathWithinMapping, Map<String, String> uriTemplateVariables) {

    HandlerExecutionChain chain = new HandlerExecutionChain(rawHandler);
    chain.addInterceptor(new PathExposingHandlerInterceptor(bestMatchingPattern, pathWithinMapping));
    if (!CollectionUtils.isEmpty(uriTemplateVariables)) {
      chain.addInterceptor(new UriTemplateVariablesHandlerInterceptor(uriTemplateVariables));
    }
    return chain;
  }
View Full Code Here

    // Bean name or resolved handler?
    if (rawHandler instanceof String) {
      String handlerName = (String) rawHandler;
      rawHandler = getApplicationContext().getBean(handlerName);
    }
    HandlerExecutionChain chain = new HandlerExecutionChain(rawHandler);
    chain.addInterceptor(new PathExposingHandlerInterceptor(pathWithinMapping));
    return chain;
  }
View Full Code Here

   * @param request current HTTP request
   * @return the HandlerExecutionChain (never <code>null</code>)
   * @see #getAdaptedInterceptors()
   */
  protected HandlerExecutionChain getHandlerExecutionChain(Object handler, HttpServletRequest request) {
    return new HandlerExecutionChain(handler, getAdaptedInterceptors());
  }
View Full Code Here

  private void doTestRequestsWithSubPaths(HandlerMapping hm) throws Exception {
    Object bean = wac.getBean("godCtrl");

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/mypath/welcome.html");
    HandlerExecutionChain hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/myapp/mypath/welcome.html");
    req.setContextPath("/myapp");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
   
    req = new MockHttpServletRequest("GET", "/myapp/mypath/welcome.html");
    req.setContextPath("/myapp");
    req.setServletPath("/mypath/welcome.html");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/myapp/myservlet/mypath/welcome.html");
    req.setContextPath("/myapp");
    req.setServletPath("/myservlet");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/myapp/myapp/mypath/welcome.html");
    req.setContextPath("/myapp");
    req.setServletPath("/myapp");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/mypath/show.html");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/mypath/bookseats.html");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
  }
View Full Code Here

    hm.setAlwaysUseFullPath(true);
    hm.setApplicationContext(wac);
    Object bean = wac.getBean("godCtrl");

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/mypath/welcome.html");
    HandlerExecutionChain hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/myapp/mypath/welcome.html");
    req.setContextPath("/myapp");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/mypath/welcome.html");
    req.setContextPath("");
    req.setServletPath("/mypath");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/Myapp/mypath/welcome.html");
    req.setContextPath("/myapp");
    req.setServletPath("/mypath");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.HandlerExecutionChain

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.