Class HandlerMethod
java.lang.Object
org.springframework.core.annotation.AnnotatedMethod
org.springframework.messaging.handler.HandlerMethod
- Direct Known Subclasses:
- InvocableHandlerMethod, InvocableHandlerMethod
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
(for example, lazy-init bean, prototype bean). Use createWithResolvedBean()
to obtain a HandlerMethod instance with a bean instance resolved
through the associated BeanFactory.
- Since:
- 4.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller
- 
Nested Class SummaryNested classes/interfaces inherited from class AnnotatedMethodAnnotatedMethod.AnnotatedMethodParameter
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final org.apache.commons.logging.LogPublic for wrapping with fallback logger.protected org.apache.commons.logging.Log
- 
Constructor SummaryConstructorsModifierConstructorDescriptionHandlerMethod(Object bean, Method method) Create an instance from a bean instance and a method.HandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) Create an instance from a bean instance, method name, and parameter types.HandlerMethod(String beanName, BeanFactory beanFactory, Method method) Create an instance from a bean name, a method, and aBeanFactory.protectedHandlerMethod(HandlerMethod handlerMethod) Copy constructor for use in subclasses.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidassertTargetBean(Method method, Object targetBean, @Nullable Object[] args) Assert that the target bean class is an instance of the class where the given method is declared.If the provided instance contains a bean name rather than an object instance, the bean name is resolved before aHandlerMethodis created and returned.booleanprotected StringformatInvokeError(String text, @Nullable Object[] args) getBean()Return the bean for this handler method.Class<?> This method returns the type of the handler for this handler method.protected Class<?> Expose the containing class for method parameters.org.apache.commons.logging.LogReturn the currently configured Logger.Return the HandlerMethod from which this HandlerMethod instance was resolved viacreateWithResolvedBean().Return a short representation of this handler method for log message purposes.inthashCode()voidsetLogger(org.apache.commons.logging.Log logger) Set an alternative logger to use than the one based on the class name.Methods inherited from class AnnotatedMethodfindProvidedArgument, formatArgumentError, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getReturnType, getReturnValueType, hasMethodAnnotation, isVoid, toString
- 
Field Details- 
defaultLoggerpublic static final org.apache.commons.logging.Log defaultLoggerPublic for wrapping with fallback logger.
- 
loggerprotected org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
HandlerMethod
- 
HandlerMethodpublic HandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException Create an instance from a bean instance, method name, and parameter types.- Throws:
- NoSuchMethodException- when the method cannot be found
 
- 
HandlerMethodCreate an instance from a bean name, a method, and aBeanFactory. The methodcreateWithResolvedBean()may be used later to re-create theHandlerMethodwith an initialized bean.
- 
HandlerMethodCopy constructor for use in subclasses.
 
- 
- 
Method Details- 
setLoggerpublic void setLogger(org.apache.commons.logging.Log logger) Set an alternative logger to use than the one based on the class name.- Parameters:
- logger- the logger to use
- Since:
- 5.1
 
- 
getLoggerpublic org.apache.commons.logging.Log getLogger()Return the currently configured Logger.- Since:
- 5.1
 
- 
getBeanReturn the bean for this handler method.
- 
getBeanTypeThis 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. 
- 
getContainingClassDescription copied from class:AnnotatedMethodExpose the containing class for method parameters.- Overrides:
- getContainingClassin class- AnnotatedMethod
- See Also:
 
- 
getResolvedFromHandlerMethodReturn the HandlerMethod from which this HandlerMethod instance was resolved viacreateWithResolvedBean().- Since:
- 4.3
 
- 
createWithResolvedBeanIf the provided instance contains a bean name rather than an object instance, the bean name is resolved before aHandlerMethodis created and returned.
- 
getShortLogMessageReturn a short representation of this handler method for log message purposes.
- 
equals- Overrides:
- equalsin class- AnnotatedMethod
 
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- AnnotatedMethod
 
- 
assertTargetBeanAssert that the target bean class is an instance of the class where the given method is declared. In some cases the actual endpoint instance at request- processing time may be a JDK dynamic proxy (lazy initialization, prototype beans, and others). Endpoint classes that require proxying should prefer class-based proxy mechanisms.
- 
formatInvokeError
 
-