类 HandlerMethod

java.lang.Object
cn.taketoday.web.handler.method.HandlerMethod
所有已实现的接口:
AsyncHandler
直接已知子类:
HandlerMethod.ConcurrentResultHandlerMethod, InvocableHandlerMethod

public class HandlerMethod extends Object implements AsyncHandler
Encapsulates information about a handler method consisting of a method and a bean. Provides convenient access to method parameters, the method return value, method annotations, etc.

The class may be created with a bean instance or with a bean name (e.g. lazy-init bean, prototype bean). Use createWithResolvedBean() to obtain a HandlerMethod instance with a bean instance resolved through the associated BeanFactory.

作者:
Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller, Sam Brannen, TODAY 2018-06-25 20:03:11
  • 字段详细资料

    • log

      protected static final cn.taketoday.logging.Logger log
      Logger that is available to subclasses.
    • contentType

      @Nullable private String contentType
      从以下版本开始:
      3.0 @Produce
    • responseBody

      @Nullable private Boolean responseBody
      从以下版本开始:
      4.0
    • interfaceParameterAnnotations

      @Nullable private volatile List<Annotation[][]> interfaceParameterAnnotations
      从以下版本开始:
      4.0
    • bean

      private final Object bean
    • beanFactory

      @Nullable private final cn.taketoday.beans.factory.BeanFactory beanFactory
    • messageSource

      @Nullable private final cn.taketoday.context.MessageSource messageSource
    • beanType

      private final Class<?> beanType
    • method

      private final Method method
      action
    • bridgedMethod

      private final Method bridgedMethod
    • parameters

      private final cn.taketoday.core.MethodParameter[] parameters
      parameter list
    • responseStatus

      @Nullable private HttpStatusCode responseStatus
    • responseStatusReason

      @Nullable private String responseStatusReason
    • resolvedFromHandlerMethod

      @Nullable private HandlerMethod resolvedFromHandlerMethod
    • description

      private final String description
    • returnType

      private final Class<?> returnType
      从以下版本开始:
      2.3.7
  • 构造器详细资料

    • HandlerMethod

      public HandlerMethod(Object bean, Method method)
      Create an instance from a bean instance and a method.
    • HandlerMethod

      protected HandlerMethod(Object bean, Method method, @Nullable cn.taketoday.context.MessageSource messageSource)
      Variant of HandlerMethod(Object, Method) that also accepts a MessageSource for use from sub-classes.
    • HandlerMethod

      public HandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException
      Create an instance from a bean instance, method name, and parameter types.
      抛出:
      NoSuchMethodException - when the method cannot be found
    • HandlerMethod

      public HandlerMethod(String beanName, cn.taketoday.beans.factory.BeanFactory beanFactory, Method method)
      Create an instance from a bean name, a method, and a BeanFactory. The method createWithResolvedBean() may be used later to re-create the HandlerMethod with an initialized bean.
    • HandlerMethod

      public HandlerMethod(String beanName, cn.taketoday.beans.factory.BeanFactory beanFactory, @Nullable cn.taketoday.context.MessageSource messageSource, Method method)
      Variant of HandlerMethod(String, BeanFactory, Method) that also accepts a MessageSource.
    • HandlerMethod

      protected HandlerMethod(HandlerMethod handlerMethod)
      Copy constructor for use in subclasses.
    • HandlerMethod

      private HandlerMethod(HandlerMethod handlerMethod, Object handler)
      Re-create HandlerMethod with the resolved handler.
  • 方法详细资料

    • initMethodParameters

      private cn.taketoday.core.MethodParameter[] initMethodParameters()
    • evaluateResponseStatus

      private void evaluateResponseStatus()
    • initDescription

      private static String initDescription(Class<?> beanType, Method method)
    • getBean

      public Object getBean()
      Return the bean for this handler method.
    • getMethod

      public Method getMethod()
      Return the method for this handler method.
    • getBeanType

      public Class<?> getBeanType()
      This method returns the type of the handler for this handler method.

      Note that if the bean type is a CGLIB-generated class, the original user-defined class is returned.

    • getBridgedMethod

      protected Method getBridgedMethod()
      If the bean method is a bridge method, this method returns the bridged (user-defined) method. Otherwise it returns the same method as getMethod().
    • getMethodParameters

      public cn.taketoday.core.MethodParameter[] getMethodParameters()
      Return the method parameters for this handler method.
    • getParameterCount

      public int getParameterCount()
      Returns the number of formal parameters (whether explicitly declared or implicitly declared or neither) for the executable represented by this object.
      返回:
      The number of formal parameters for the executable this object represents
      从以下版本开始:
      4.0
    • getResponseStatus

      @Nullable protected HttpStatusCode getResponseStatus()
      Return the specified response status, if any.
      另请参阅:
    • getResponseStatusReason

      @Nullable protected String getResponseStatusReason()
      Return the associated response status reason, if any.
      另请参阅:
    • getReturnType

      public cn.taketoday.core.MethodParameter getReturnType()
      Return the HandlerMethod return type.
    • getReturnValueType

      public cn.taketoday.core.MethodParameter getReturnValueType(@Nullable Object returnValue)
      Return the actual return value type.
    • getRawReturnType

      public Class<?> getRawReturnType()
      Return the actual return type.
    • isReturnTypeAssignableTo

      public boolean isReturnTypeAssignableTo(Class<?> superClass)
    • isReturn

      public boolean isReturn(Class<?> returnType)
    • setContentType

      public void setContentType(@Nullable String contentType)
    • getContentType

      @Nullable public String getContentType()
    • isResponseBody

      public boolean isResponseBody()
      ResponseBody present?
    • computeResponseBody

      protected boolean computeResponseBody()
    • isVoid

      public boolean isVoid()
      Return true if the method return type is void, false otherwise.
    • getMethodAnnotation

      @Nullable public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType)
      Return a single annotation on the underlying method traversing its super methods if no annotation can be found on the given method itself.

      Also supports merged composed annotations with attribute overrides

      参数:
      annotationType - the type of annotation to introspect the method for
      返回:
      the annotation, or null if none found
      另请参阅:
      • AnnotatedElementUtils.findMergedAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<A>)
    • hasMethodAnnotation

      public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType)
      Return whether the parameter is declared with the given annotation type.
      参数:
      annotationType - the annotation type to look for
      从以下版本开始:
      4.0
      另请参阅:
      • AnnotatedElementUtils.hasAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
    • getResolvedFromHandlerMethod

      @Nullable public HandlerMethod getResolvedFromHandlerMethod()
      Return the HandlerMethod from which this HandlerMethod instance was resolved via createWithResolvedBean().
      从以下版本开始:
      4.0
    • wrapConcurrentResult

      public HandlerMethod.ConcurrentResultHandlerMethod wrapConcurrentResult(Object result)
      指定者:
      wrapConcurrentResult 在接口中 AsyncHandler
    • createWithResolvedBean

      public HandlerMethod createWithResolvedBean()
      If the provided instance contains a bean name rather than an object instance, the bean name is resolved before a HandlerMethod is created and returned.
      从以下版本开始:
      4.0
    • getShortLogMessage

      public String getShortLogMessage()
      Return a short representation of this handler method for log message purposes.
      从以下版本开始:
      4.0
    • getInterfaceParameterAnnotations

      private List<Annotation[][]> getInterfaceParameterAnnotations()
    • isOverrideFor

      private boolean isOverrideFor(Method candidate)
    • equals

      public boolean equals(@Nullable Object other)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • findProvidedArgument

      @Nullable protected static Object findProvidedArgument(cn.taketoday.core.MethodParameter parameter, @Nullable Object... providedArgs)
    • formatArgumentError

      protected static String formatArgumentError(ResolvableMethodParameter param, String message)
    • assertTargetBean

      protected void assertTargetBean(Method method, Object targetBean, Object[] args)
      Assert that the target bean class is an instance of the class where the given method is declared. In some cases the actual controller instance at request- processing time may be a JDK dynamic proxy (lazy initialization, prototype beans, and others). @Controller's that require proxying should prefer class-based proxy mechanisms.
    • formatInvokeError

      protected String formatInvokeError(String text, Object[] args)
    • isResponseBody

      public static boolean isResponseBody(Method method)
      从以下版本开始:
      4.0
    • getStatusValue

      public static int getStatusValue(Throwable ex)
    • getResponseStatus

      public static ResponseStatus getResponseStatus(Throwable ex)
    • getResponseStatus

      public static ResponseStatus getResponseStatus(Class<? extends Throwable> exceptionClass)
    • unwrap

      @Nullable public static HandlerMethod unwrap(@Nullable Object handler)