Top Description Inners Fields Constructors Methods
org.springframework.web.method.support

public Class InvocableHandlerMethod

extends HandlerMethod
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, .Method, .Modifier, java.util.Arrays, .Map, kotlin.Unit, kotlin.jvm.JvmClassMappingKt, kotlin.reflect.KClass, kotlin.reflect.KFunction, kotlin.reflect.KParameter, kotlin.reflect.jvm.KCallablesJvm, kotlin.reflect.jvm.ReflectJvmMapping, org.springframework.context.MessageSource, org.springframework.core.CoroutinesUtils, .DefaultParameterNameDiscoverer, .KotlinDetector, .MethodParameter, .ParameterNameDiscoverer, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .ObjectUtils, .ReflectionUtils, org.springframework.validation.method.MethodValidator, org.springframework.web.bind.WebDataBinder, org.springframework.web.bind.support.SessionStatus, .WebDataBinderFactory, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.method.HandlerMethod

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, Sebastien Deleuze
Since
3.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
InvocableHandlerMethod.KotlinDelegate

Inner class to avoid a hard dependency on Kotlin at runtime.

Field Summary

Modifier and TypeField and Description
private static final ReflectionUtils.MethodFilter
private WebDataBinderFactory
private static final Object[]
private static final Class<?>[]
private MethodValidator
private ParameterNameDiscoverer
private HandlerMethodArgumentResolverComposite
private Class<?>[]
Inherited from org.springframework.web.method.HandlerMethod:
logger

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.

protected
InvocableHandlerMethod(Object bean, Method method, MessageSource messageSource)

Variant of InvocableHandlerMethod(Object, Method) that also accepts a MessageSource, for use in subclasses.

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.

protected Object[]
getMethodArgumentValues(NativeWebRequest request, ModelAndViewContainer mavContainer, Object... providedArgs)

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

public Object

Returns:

the raw value returned by the invoked method
invokeForRequest
(NativeWebRequest
the current request
request
,
ModelAndViewContainer
the ModelAndViewContainer for this request
mavContainer
,
Object...
"given" arguments matched by type, not resolved
providedArgs
)

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

protected Object
invokeSuspendingFunction(Method method, Object target, Object[] args)

Invoke the given Kotlin coroutine suspended function.

public void
setDataBinderFactory(WebDataBinderFactory dataBinderFactory)

Set the WebDataBinderFactory to be passed to argument resolvers allowing them to create a WebDataBinder for data binding and type conversion purposes.

public void
setHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)

Set HandlerMethodArgumentResolvers to use for resolving method argument values.

public void
setMethodValidator(MethodValidator methodValidator)

Set the MethodValidator to perform method validation with if the controller method shouldValidateArguments() or shouldValidateReturnValue().

public void
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)

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

Inherited from org.springframework.web.method.HandlerMethod:
assertTargetBeancreateWithResolvedBeancreateWithValidateFlagsequalsformatInvokeErrorgetBeangetBeanTypegetContainingClassgetResolvedFromHandlerMethodgetResponseStatusgetResponseStatusReasongetShortLogMessagehashCodeshouldValidateArgumentsshouldValidateReturnValuetoString

Field Detail

boxImplFilterback to summary
private static final ReflectionUtils.MethodFilter boxImplFilter
dataBinderFactoryback to summary
private WebDataBinderFactory dataBinderFactory
Annotations
@Nullable
EMPTY_ARGSback to summary
private static final Object[] EMPTY_ARGS
EMPTY_GROUPSback to summary
private static final Class<?>[] EMPTY_GROUPS
methodValidatorback to summary
private MethodValidator methodValidator
Annotations
@Nullable
parameterNameDiscovererback to summary
private ParameterNameDiscoverer parameterNameDiscoverer
resolversback to summary
private HandlerMethodArgumentResolverComposite resolvers
validationGroupsback to summary
private Class<?>[] validationGroups

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
protected InvocableHandlerMethod(Object bean, Method method, MessageSource messageSource)

Variant of InvocableHandlerMethod(Object, Method) that also accepts a MessageSource, for use in subclasses.

Since
5.3.10
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
getMethodArgumentValuesback to summary
protected Object[] getMethodArgumentValues(NativeWebRequest request, ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception

Get the method argument values for the current request, 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
invokeForRequestback to summary
public Object invokeForRequest(NativeWebRequest request, ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception

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

Argument values are commonly resolved through HandlerMethodArgumentResolvers. The providedArgs parameter however may supply argument values to be used directly, i.e. without argument resolution. Examples of provided argument values include a WebDataBinder, a SessionStatus, or a thrown exception instance. Provided argument values are checked before argument resolvers.

Delegates to getMethodArgumentValues and calls doInvoke with the resolved arguments.

Parameters
request:NativeWebRequest

the current request

mavContainer:ModelAndViewContainer

the ModelAndViewContainer for this request

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
invokeSuspendingFunctionback to summary
protected Object invokeSuspendingFunction(Method method, Object target, Object[] args)

Invoke the given Kotlin coroutine suspended function.

The default implementation invokes CoroutinesUtils#invokeSuspendingFunction(Method, Object, Object...), but subclasses can override this method to use CoroutinesUtils#invokeSuspendingFunction(kotlin.coroutines.CoroutineContext, Method, Object, Object...) instead.

Since
6.0
setDataBinderFactoryback to summary
public void setDataBinderFactory(WebDataBinderFactory dataBinderFactory)

Set the WebDataBinderFactory to be passed to argument resolvers allowing them to create a WebDataBinder for data binding and type conversion purposes.

setHandlerMethodArgumentResolversback to summary
public void setHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)

Set HandlerMethodArgumentResolvers to use for resolving method argument values.

setMethodValidatorback to summary
public void setMethodValidator(MethodValidator methodValidator)

Set the MethodValidator to perform method validation with if the controller method shouldValidateArguments() or shouldValidateReturnValue().

Since
6.1
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.web.method.support back to summary

private Class InvocableHandlerMethod.KotlinDelegate

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.method.support.InvocableHandlerMethod.KotlinDelegate

Inner class to avoid a hard dependency on Kotlin at runtime.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Object
invokeFunction(Method method, Object target, Object[] args)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

KotlinDelegateback to summary
private KotlinDelegate()

Method Detail

invokeFunctionback to summary
public static Object invokeFunction(Method method, Object target, Object[] args) throws InvocationTargetException, IllegalAccessException
Annotations
@Nullable
@SuppressWarnings:deprecation