类 InvocableHandlerMethod
- java.lang.Object
- org.springframework.messaging.handler.HandlerMethod
- org.springframework.messaging.handler.invocation.InvocableHandlerMethod
public class InvocableHandlerMethod extends HandlerMethod
Provides a method for invoking the handler method for a given message after resolving its method argument values through registeredHandlerMethodArgumentResolver
s.Use
setMessageMethodArgumentResolvers(org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverComposite)
to customize the list of argument resolvers.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
嵌套类概要
从类继承的嵌套类/接口 org.springframework.messaging.handler.HandlerMethod
HandlerMethod.HandlerMethodParameter
字段概要
从类继承的字段 org.springframework.messaging.handler.HandlerMethod
logger
构造器概要
构造器 构造器 说明 InvocableHandlerMethod(Object bean, Method method)
Create an instance from a bean instance and a method.InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes)
Construct a new handler method with the given bean instance, method name and parameters.InvocableHandlerMethod(HandlerMethod handlerMethod)
Create an instance from aHandlerMethod
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Object
doInvoke(Object... args)
Invoke the handler method with the given argument values.protected String
getDetailedErrorMessage(String text)
Adds HandlerMethod details such as the bean type and method signature to the message.Object
invoke(Message<?> message, Object... providedArgs)
Invoke the method after resolving its argument values in the context of the given message.void
setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
SetHandlerMethodArgumentResolver
s to use to use for resolving method argument values.void
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).从类继承的方法 org.springframework.messaging.handler.HandlerMethod
createWithResolvedBean, equals, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getResolvedFromHandlerMethod, getReturnType, getReturnValueType, getShortLogMessage, hashCode, hasMethodAnnotation, isVoid, toString
构造器详细资料
InvocableHandlerMethod
public InvocableHandlerMethod(HandlerMethod handlerMethod)
Create an instance from aHandlerMethod
.
InvocableHandlerMethod
public InvocableHandlerMethod(Object bean, Method method)
Create an instance from a bean instance and a method.
InvocableHandlerMethod
public InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException
Construct a new handler method with the given bean instance, method name and parameters.- 参数:
bean
- the object beanmethodName
- the method nameparameterTypes
- the method parameter types- 抛出:
NoSuchMethodException
- when the method cannot be found
方法详细资料
setMessageMethodArgumentResolvers
public void setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
SetHandlerMethodArgumentResolver
s to use to use for resolving method argument values.
setParameterNameDiscoverer
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).Default is a
DefaultParameterNameDiscoverer
.
invoke
public Object invoke(Message<?> message, Object... providedArgs) throws Exception
Invoke the method after resolving its argument values in the context of the given message.Argument values are commonly resolved through
HandlerMethodArgumentResolver
s. TheprovidedArgs
parameter however may supply argument values to be used directly, i.e. without argument resolution.- 参数:
message
- the current message being processedprovidedArgs
- "given" arguments matched by type, not resolved- 返回:
- the raw value returned by the invoked method
- 抛出:
Exception
- raised if no suitable argument resolver can be found, or if the method raised an exception
doInvoke
protected Object doInvoke(Object... args) throws Exception
Invoke the handler method with the given argument values.- 抛出:
Exception
getDetailedErrorMessage
protected String getDetailedErrorMessage(String text)
Adds HandlerMethod details such as the bean type and method signature to the message.- 参数:
text
- error message to append the HandlerMethod details to