类 HandlerMethod
java.lang.Object
cn.taketoday.web.handler.method.HandlerMethod
- 所有已实现的接口:
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
-
嵌套类概要
嵌套类修饰符和类型类说明protected static classprivate classMethodParameter subclass based on the actual return value type or if that's null falling back on the generic type within the declared async return type, e.g.protected classA MethodParameter with HandlerMethod-specific behavior.private classA MethodParameter for a HandlerMethod return type based on an actual return value. -
字段概要
字段修饰符和类型字段说明private final Objectprivate final cn.taketoday.beans.factory.BeanFactoryprivate final Class<?>private final Methodprivate Stringprivate final Stringprivate List<Annotation[][]>protected static final cn.taketoday.logging.LoggerLogger that is available to subclasses.private final cn.taketoday.context.MessageSourceprivate final Methodactionprivate final cn.taketoday.core.MethodParameter[]parameter listprivate HandlerMethodprivate Booleanprivate HttpStatusCodeprivate Stringprivate final Class<?> -
构造器概要
构造器限定符构造器说明protectedHandlerMethod(HandlerMethod handlerMethod) Copy constructor for use in subclasses.privateHandlerMethod(HandlerMethod handlerMethod, Object handler) Re-create HandlerMethod with the resolved handler.HandlerMethod(Object bean, Method method) Create an instance from a bean instance and a method.protectedHandlerMethod(Object bean, Method method, cn.taketoday.context.MessageSource messageSource) Variant ofHandlerMethod(Object, Method)that also accepts aMessageSourcefor use from sub-classes.HandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) Create an instance from a bean instance, method name, and parameter types.HandlerMethod(String beanName, cn.taketoday.beans.factory.BeanFactory beanFactory, cn.taketoday.context.MessageSource messageSource, Method method) Variant ofHandlerMethod(String, BeanFactory, Method)that also accepts aMessageSource.HandlerMethod(String beanName, cn.taketoday.beans.factory.BeanFactory beanFactory, Method method) Create an instance from a bean name, a method, and aBeanFactory. -
方法概要
修饰符和类型方法说明protected voidassertTargetBean(Method method, Object targetBean, Object[] args) Assert that the target bean class is an instance of the class where the given method is declared.protected booleanIf the provided instance contains a bean name rather than an object instance, the bean name is resolved before aHandlerMethodis created and returned.booleanprivate voidprotected static ObjectfindProvidedArgument(cn.taketoday.core.MethodParameter parameter, Object... providedArgs) protected static StringformatArgumentError(ResolvableMethodParameter param, String message) protected StringformatInvokeError(String text, Object[] args) getBean()Return the bean for this handler method.Class<?>This method returns the type of the handler for this handler method.protected MethodIf the bean method is a bridge method, this method returns the bridged (user-defined) method.private List<Annotation[][]>Return the method for this handler method.<A extends Annotation>
AgetMethodAnnotation(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.cn.taketoday.core.MethodParameter[]Return the method parameters for this handler method.intReturns the number of formal parameters (whether explicitly declared or implicitly declared or neither) for the executable represented by this object.Class<?>Return the actual return type.Return the HandlerMethod from which this HandlerMethod instance was resolved viacreateWithResolvedBean().protected HttpStatusCodeReturn the specified response status, if any.static ResponseStatusgetResponseStatus(Class<? extends Throwable> exceptionClass) static ResponseStatusprotected StringReturn the associated response status reason, if any.cn.taketoday.core.MethodParameterReturn the HandlerMethod return type.cn.taketoday.core.MethodParametergetReturnValueType(Object returnValue) Return the actual return value type.Return a short representation of this handler method for log message purposes.static intinthashCode()<A extends Annotation>
booleanhasMethodAnnotation(Class<A> annotationType) Return whether the parameter is declared with the given annotation type.private static StringinitDescription(Class<?> beanType, Method method) private cn.taketoday.core.MethodParameter[]private booleanisOverrideFor(Method candidate) booleanResponseBody present?static booleanisResponseBody(Method method) booleanbooleanisReturnTypeAssignableTo(Class<?> superClass) booleanisVoid()Returntrueif the method return type is void,falseotherwise.voidsetContentType(String contentType) toString()static HandlerMethodwrapConcurrentResult(Object result)
-
字段详细资料
-
log
protected static final cn.taketoday.logging.Logger logLogger that is available to subclasses. -
contentType
- 从以下版本开始:
- 3.0 @Produce
-
responseBody
- 从以下版本开始:
- 4.0
-
interfaceParameterAnnotations
- 从以下版本开始:
- 4.0
-
bean
-
beanFactory
@Nullable private final cn.taketoday.beans.factory.BeanFactory beanFactory -
messageSource
@Nullable private final cn.taketoday.context.MessageSource messageSource -
beanType
-
method
action -
bridgedMethod
-
parameters
private final cn.taketoday.core.MethodParameter[] parametersparameter list -
responseStatus
-
responseStatusReason
-
resolvedFromHandlerMethod
-
description
-
returnType
- 从以下版本开始:
- 2.3.7
-
-
构造器详细资料
-
HandlerMethod
Create an instance from a bean instance and a method. -
HandlerMethod
protected HandlerMethod(Object bean, Method method, @Nullable cn.taketoday.context.MessageSource messageSource) Variant ofHandlerMethod(Object, Method)that also accepts aMessageSourcefor 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 aBeanFactory. The methodcreateWithResolvedBean()may be used later to re-create theHandlerMethodwith an initialized bean. -
HandlerMethod
public HandlerMethod(String beanName, cn.taketoday.beans.factory.BeanFactory beanFactory, @Nullable cn.taketoday.context.MessageSource messageSource, Method method) Variant ofHandlerMethod(String, BeanFactory, Method)that also accepts aMessageSource. -
HandlerMethod
Copy constructor for use in subclasses. -
HandlerMethod
Re-create HandlerMethod with the resolved handler.
-
-
方法详细资料
-
initMethodParameters
private cn.taketoday.core.MethodParameter[] initMethodParameters() -
evaluateResponseStatus
private void evaluateResponseStatus() -
initDescription
-
getBean
Return the bean for this handler method. -
getMethod
Return the method for this handler method. -
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
If the bean method is a bridge method, this method returns the bridged (user-defined) method. Otherwise it returns the same method asgetMethod(). -
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
Return the specified response status, if any.- 另请参阅:
-
getResponseStatusReason
Return the associated response status reason, if any.- 另请参阅:
-
getReturnType
public cn.taketoday.core.MethodParameter getReturnType()Return the HandlerMethod return type. -
getReturnValueType
Return the actual return value type. -
getRawReturnType
Return the actual return type. -
isReturnTypeAssignableTo
-
isReturn
-
setContentType
-
getContentType
-
isResponseBody
public boolean isResponseBody()ResponseBody present? -
computeResponseBody
protected boolean computeResponseBody() -
isVoid
public boolean isVoid()Returntrueif the method return type is void,falseotherwise. -
getMethodAnnotation
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
nullif none found - 另请参阅:
-
AnnotatedElementUtils.findMergedAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<A>)
-
hasMethodAnnotation
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
Return the HandlerMethod from which this HandlerMethod instance was resolved viacreateWithResolvedBean().- 从以下版本开始:
- 4.0
-
wrapConcurrentResult
- 指定者:
wrapConcurrentResult在接口中AsyncHandler
-
createWithResolvedBean
If the provided instance contains a bean name rather than an object instance, the bean name is resolved before aHandlerMethodis created and returned.- 从以下版本开始:
- 4.0
-
getShortLogMessage
Return a short representation of this handler method for log message purposes.- 从以下版本开始:
- 4.0
-
getInterfaceParameterAnnotations
-
isOverrideFor
-
equals
-
hashCode
public int hashCode() -
toString
-
findProvidedArgument
-
formatArgumentError
-
assertTargetBean
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
-
isResponseBody
- 从以下版本开始:
- 4.0
-
getStatusValue
-
getResponseStatus
-
getResponseStatus
-
unwrap
-