Package org.springframework.web.method

Examples of org.springframework.web.method.HandlerMethod


  }

  @Test
  public void resolveArgumentTypeVariable() throws Exception {
    Method method = MySimpleParameterizedController.class.getMethod("handleDto", HttpEntity.class);
    HandlerMethod handlerMethod = new HandlerMethod(new MySimpleParameterizedController(), method);
    MethodParameter methodParam = handlerMethod.getMethodParameters()[0];

    String content = "{\"name\" : \"Jad\"}";
    this.servletRequest.setContent(content.getBytes("UTF-8"));
    this.servletRequest.setContentType(MediaType.APPLICATION_JSON_VALUE);
View Full Code Here


  }


  @Test
  public void cacheControlWithoutSessionAttributes() throws Exception {
    HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handle");
    this.handlerAdapter.setCacheSeconds(100);
    this.handlerAdapter.afterPropertiesSet();

    this.handlerAdapter.handle(this.request, this.response, handlerMethod);
    assertTrue(response.getHeader("Cache-Control").contains("max-age"));
View Full Code Here

    this.handlerAdapter.setIgnoreDefaultModelOnRedirect(true);
    this.handlerAdapter.afterPropertiesSet();

    this.request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());

    HandlerMethod handlerMethod = handlerMethod(new RedirectAttributeController(), "handle", Model.class);
    ModelAndView mav = this.handlerAdapter.handle(request, response, handlerMethod);

    assertTrue("Without RedirectAttributes arg, model should be empty", mav.getModel().isEmpty());
  }
View Full Code Here

  @Test
  public void modelAttributeAdvice() throws Exception {
    this.webAppContext.registerSingleton("maa", ModelAttributeAdvice.class);
    this.webAppContext.refresh();

    HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handle");
    this.handlerAdapter.afterPropertiesSet();
    ModelAndView mav = this.handlerAdapter.handle(this.request, this.response, handlerMethod);

    assertEquals("lAttr1", mav.getModel().get("attr1"));
    assertEquals("gAttr2", mav.getModel().get("attr2"));
View Full Code Here

    parent.registerSingleton("maa", ModelAttributeAdvice.class);
    parent.refresh();
    this.webAppContext.setParent(parent);
    this.webAppContext.refresh();

    HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handle");
    this.handlerAdapter.afterPropertiesSet();
    ModelAndView mav = this.handlerAdapter.handle(this.request, this.response, handlerMethod);

    assertEquals("lAttr1", mav.getModel().get("attr1"));
    assertEquals("gAttr2", mav.getModel().get("attr2"));
View Full Code Here

  public void modelAttributePackageNameAdvice() throws Exception {
    this.webAppContext.registerSingleton("mapa", ModelAttributePackageAdvice.class);
    this.webAppContext.registerSingleton("manupa", ModelAttributeNotUsedPackageAdvice.class);
    this.webAppContext.refresh();

    HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handle");
    this.handlerAdapter.afterPropertiesSet();
    ModelAndView mav = this.handlerAdapter.handle(this.request, this.response, handlerMethod);

    assertEquals("lAttr1", mav.getModel().get("attr1"));
    assertEquals("gAttr2", mav.getModel().get("attr2"));
View Full Code Here

    this.webAppContext.refresh();

    this.request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
    this.request.setParameter("c", "callback");

    HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handleWithResponseEntity");
    this.handlerAdapter.afterPropertiesSet();
    this.handlerAdapter.handle(this.request, this.response, handlerMethod);

    assertEquals(200, this.response.getStatus());
    assertEquals("callback({\"status\":400,\"message\":\"body\"});", this.response.getContentAsString());
View Full Code Here

    }
    Collections.shuffle(modelMethods);

    SessionAttributesHandler sessionHandler = new SessionAttributesHandler(type, this.sessionAttributeStore);
    ModelFactory factory = new ModelFactory(modelMethods, dataBinderFactory, sessionHandler);
    factory.initModel(this.webRequest, this.mavContainer, new HandlerMethod(controller, "handle"));
    if (logger.isDebugEnabled()) {
      StringBuilder sb = new StringBuilder();
      for (String name : getInvokedMethods()) {
        sb.append(" >> ").append(name);
      }
View Full Code Here

    if (handler == null) {
      this.printer.printValue("Type", null);
    }
    else {
      if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        this.printer.printValue("Type", handlerMethod.getBeanType().getName());
        this.printer.printValue("Method", handlerMethod);
      }
      else {
        this.printer.printValue("Type", handler.getClass().getName());
      }
View Full Code Here

   
    if (!(handler instanceof HandlerMethod)) {
      return ;
    }
   
    final HandlerMethod handlerMethod = (HandlerMethod)handler;
    Method method = handlerMethod.getMethod();
   
    final Log log = method.getAnnotation(Log.class);
    if (log != null) {
      // 得到LogMessageObject
      final LogMessageObject logMessageObject = LogUitls.getArgs();
      // 另起线程异步操作
      new Thread(new Runnable() {
       
        @Override
        public void run() {
          try {
            LogLevel lastLogLevel = logAPI.getRootLogLevel();
           
            // 先对自定义包等级做判断
            Map<String, LogLevel> customLogLevel = logAPI.getCustomLogLevel();
            if (!customLogLevel.isEmpty()) {
              Class<?> clazz = handlerMethod.getBean().getClass();
              String packageName = clazz.getPackage().getName();
             
              Set<String> keys = customLogLevel.keySet();
              for (String key : keys) {
                if (packageName.startsWith(key)) {
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.