Package org.springframework.web.method.annotation

Examples of org.springframework.web.method.annotation.ExceptionHandlerMethodResolver


  /**
   * Return a method resolver for the given handler type, never {@code null}.
   */
  private ExceptionHandlerMethodResolver getExceptionHandlerMethodResolver(Class<?> handlerType) {
    ExceptionHandlerMethodResolver resolver = this.exceptionHandlerMethodResolvers.get(handlerType);
    if (resolver == null) {
      resolver = new ExceptionHandlerMethodResolver(handlerType);
      this.exceptionHandlerMethodResolvers.put(handlerType, resolver);
    }
    return resolver;
  }
View Full Code Here


    List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
    Collections.sort(beans, new OrderComparator());

    for (ControllerAdviceBean bean : beans) {
      ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(bean.getBeanType());
      if (resolver.hasExceptionMappings()) {
        this.exceptionHandlerAdviceCache.put(bean, resolver);
        logger.info("Detected @ExceptionHandler methods in " + bean);
      }
    }
  }
View Full Code Here

   * @return a method to handle the exception, or {@code null}
   */
  protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) {
    if (handlerMethod != null) {
      Class<?> handlerType = handlerMethod.getBeanType();
      ExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.get(handlerType);
      if (resolver == null) {
        resolver = new ExceptionHandlerMethodResolver(handlerType);
        this.exceptionHandlerCache.put(handlerType, resolver);
      }
      Method method = resolver.resolveMethod(exception);
      if (method != null) {
        return new ServletInvocableHandlerMethod(handlerMethod.getBean(), method);
      }
    }
    for (Entry<ControllerAdviceBean, ExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
View Full Code Here

  /**
   * Provide a handler with @{@link ExceptionHandler} methods.
   */
  public void setExceptionHandler(Object handler) {
    this.handler = handler;
    this.methodResolver = new ExceptionHandlerMethodResolver(handler.getClass());
  }
View Full Code Here

    List<ControllerAdviceBean> adviceBeans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
    Collections.sort(adviceBeans, new OrderComparator());

    for (ControllerAdviceBean adviceBean : adviceBeans) {
      ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(adviceBean.getBeanType());
      if (resolver.hasExceptionMappings()) {
        this.exceptionHandlerAdviceCache.put(adviceBean, resolver);
        logger.info("Detected @ExceptionHandler methods in " + adviceBean);
      }
      if (ResponseBodyAdvice.class.isAssignableFrom(adviceBean.getBeanType())) {
        this.responseBodyAdvice.add(adviceBean);
View Full Code Here

   */
  protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) {
    Class<?> handlerType = (handlerMethod != null ? handlerMethod.getBeanType() : null);

    if (handlerMethod != null) {
      ExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.get(handlerType);
      if (resolver == null) {
        resolver = new ExceptionHandlerMethodResolver(handlerType);
        this.exceptionHandlerCache.put(handlerType, resolver);
      }
      Method method = resolver.resolveMethod(exception);
      if (method != null) {
        return new ServletInvocableHandlerMethod(handlerMethod.getBean(), method);
      }
    }

    for (Entry<ControllerAdviceBean, ExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
      if (entry.getKey().isApplicableToBeanType(handlerType)) {
        ExceptionHandlerMethodResolver resolver = entry.getValue();
        Method method = resolver.resolveMethod(exception);
        if (method != null) {
          return new ServletInvocableHandlerMethod(entry.getKey().resolveBean(), method);
        }
      }
    }
View Full Code Here

  /**
   * Provide a handler with @{@link ExceptionHandler} methods.
   */
  public void setExceptionHandler(Object handler) {
    this.handler = handler;
    this.methodResolver = new ExceptionHandlerMethodResolver(handler.getClass());
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.method.annotation.ExceptionHandlerMethodResolver

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.