Top Description Inners Fields Constructors Methods
org.springframework.messaging.handler.invocation

public Class InvocableHandlerMethod

extends HandlerMethod
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, .Method, .Type, java.util.Arrays, org.springframework.core.DefaultParameterNameDiscoverer, .MethodParameter, .ParameterNameDiscoverer, .ResolvableType, org.springframework.lang.Nullable, org.springframework.messaging.Message, org.springframework.messaging.handler.HandlerMethod, org.springframework.util.ObjectUtils

Extension of HandlerMethod that invokes the underlying method with argument values resolved from the current HTTP request through a list of HandlerMethodArgumentResolver.
Authors
Rossen Stoyanchev, Juergen Hoeller
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static final Object[]
private ParameterNameDiscoverer
private HandlerMethodArgumentResolverComposite
Inherited from org.springframework.messaging.handler.HandlerMethod:
defaultLoggerlogger

Constructor Summary

AccessConstructor and Description
public
InvocableHandlerMethod(HandlerMethod handlerMethod)

Create an instance from a HandlerMethod.

public
InvocableHandlerMethod(Object bean, Method method)

Create an instance from a bean instance and a method.

public
InvocableHandlerMethod(Object
the object bean
bean
,
String
the method name
methodName
,
Class<?>...
the method parameter types
parameterTypes
)

Construct a new handler method with the given bean instance, method name and parameters.

Method Summary

Modifier and TypeMethod and Description
protected Object
doInvoke(Object... args)

Invoke the handler method with the given argument values.

pack-priv MethodParameter
protected Object[]
getMethodArgumentValues(Message<?> message, Object... providedArgs)

Get the method argument values for the current message, checking the provided argument values and falling back to the configured argument resolvers.

public Object

Returns:

the raw value returned by the invoked method
invoke
(Message<?>
the current message being processed
message
,
Object...
"given" arguments matched by type, not resolved
providedArgs
)

Invoke the method after resolving its argument values in the context of the given message.

public void
setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)

Set HandlerMethodArgumentResolvers to use for resolving method argument values.

public void
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)

Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).

Inherited from org.springframework.messaging.handler.HandlerMethod:
assertTargetBeancreateWithResolvedBeanequalsformatInvokeErrorgetBeangetBeanTypegetContainingClassgetLoggergetResolvedFromHandlerMethodgetShortLogMessagehashCodesetLogger

Field Detail

EMPTY_ARGSback to summary
private static final Object[] EMPTY_ARGS
parameterNameDiscovererback to summary
private ParameterNameDiscoverer parameterNameDiscoverer
resolversback to summary
private HandlerMethodArgumentResolverComposite resolvers

Constructor Detail

InvocableHandlerMethodback to summary
public InvocableHandlerMethod(HandlerMethod handlerMethod)

Create an instance from a HandlerMethod.

InvocableHandlerMethodback to summary
public InvocableHandlerMethod(Object bean, Method method)

Create an instance from a bean instance and a method.

InvocableHandlerMethodback to summary
public InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException

Construct a new handler method with the given bean instance, method name and parameters.

Parameters
bean:Object

the object bean

methodName:String

the method name

parameterTypes:Class<?>[]

the method parameter types

Exceptions
NoSuchMethodException:
when the method cannot be found

Method Detail

doInvokeback to summary
protected Object doInvoke(Object... args) throws Exception

Invoke the handler method with the given argument values.

Annotations
@Nullable
getAsyncReturnValueTypeback to summary
pack-priv MethodParameter getAsyncReturnValueType(Object returnValue)
getMethodArgumentValuesback to summary
protected Object[] getMethodArgumentValues(Message<?> message, Object... providedArgs) throws Exception

Get the method argument values for the current message, checking the provided argument values and falling back to the configured argument resolvers.

The resulting array will be passed into doInvoke.

Since
5.1.2
invokeback to summary
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 HandlerMethodArgumentResolvers. The providedArgs parameter however may supply argument values to be used directly, i.e. without argument resolution.

Delegates to getMethodArgumentValues and calls doInvoke with the resolved arguments.

Parameters
message:Message<?>

the current message being processed

providedArgs:Object[]

"given" arguments matched by type, not resolved

Returns:Object

the raw value returned by the invoked method

Annotations
@Nullable
Exceptions
Exception:
raised if no suitable argument resolver can be found, or if the method raised an exception
See Also
getMethodArgumentValues, doInvoke
setMessageMethodArgumentResolversback to summary
public void setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)

Set HandlerMethodArgumentResolvers to use for resolving method argument values.

setParameterNameDiscovererback to summary
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)

Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).

Default is a org.springframework.core.DefaultParameterNameDiscoverer.

org.springframework.messaging.handler.invocation back to summary

private Class InvocableHandlerMethod.AsyncResultMethodParameter

extends AnnotatedMethodParameter
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ResolvableType
private final Object

Constructor Summary

AccessConstructor and Description
public
protected

Method Summary

Modifier and TypeMethod and Description
public InvocableHandlerMethod.AsyncResultMethodParameter
public Type
getGenericParameterType()

Overrides org.springframework.core.MethodParameter.getGenericParameterType.

Return the generic type of the method/constructor parameter.
public Class<?>
getParameterType()

Overrides org.springframework.core.MethodParameter.getParameterType.

Return the type of the method/constructor parameter.
Inherited from org.springframework.core.annotation.AnnotatedMethod.AnnotatedMethodParameter:
getContainingClassgetMethodgetMethodAnnotationgetParameterAnnotationshasMethodAnnotation

Field Detail

returnTypeback to summary
private final ResolvableType returnType
returnValueback to summary
private final Object returnValue
Annotations
@Nullable

Constructor Detail

AsyncResultMethodParameterback to summary
public AsyncResultMethodParameter(Object returnValue)
AsyncResultMethodParameterback to summary
protected AsyncResultMethodParameter(InvocableHandlerMethod.AsyncResultMethodParameter original)

Method Detail

cloneback to summary
public InvocableHandlerMethod.AsyncResultMethodParameter clone()

Overrides org.springframework.core.annotation.AnnotatedMethod.AnnotatedMethodParameter.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:InvocableHandlerMethod.AsyncResultMethodParameter

a clone of this instance.

Annotations
@Override
getGenericParameterTypeback to summary
public Type getGenericParameterType()

Overrides org.springframework.core.MethodParameter.getGenericParameterType.

Doc from org.springframework.core.MethodParameter.getGenericParameterType.

Return the generic type of the method/constructor parameter.

Returns:Type

the parameter type (never null)

Annotations
@Override
getParameterTypeback to summary
public Class<?> getParameterType()

Overrides org.springframework.core.MethodParameter.getParameterType.

Doc from org.springframework.core.MethodParameter.getParameterType.

Return the type of the method/constructor parameter.

Returns:Class<?>

the parameter type (never null)

Annotations
@Override