Top Description Inners Fields Constructors Methods
org.springframework.web.servlet.mvc.method.annotation

public Class ServletInvocableHandlerMethod

extends InvocableHandlerMethod
Class Inheritance
Known Direct Subclasses
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.ConcurrentResultHandlerMethod
Imports
java.io.IOException, java.lang.annotation.Annotation, java.lang.reflect.Method, .Type, java.util.concurrent.Callable, jakarta.servlet.ServletException, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.springframework.context.MessageSource, org.springframework.core.KotlinDetector, .MethodParameter, .ResolvableType, org.springframework.http.HttpHeaders, .HttpStatusCode, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .StringUtils, org.springframework.web.bind.annotation.ResponseBody, .ResponseStatus, org.springframework.web.context.request.ServletWebRequest, org.springframework.web.method.HandlerMethod, org.springframework.web.method.support.HandlerMethodReturnValueHandler, .HandlerMethodReturnValueHandlerComposite, .InvocableHandlerMethod, .ModelAndViewContainer, org.springframework.web.servlet.View, org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler.CollectedValuesList

Extends InvocableHandlerMethod with the ability to handle return values through a registered HandlerMethodReturnValueHandler and also supports setting the response status based on a method-level @ResponseStatus annotation.

A null return value (including void) may be interpreted as the end of request processing in combination with a @ResponseStatus annotation, a not-modified check condition (see ServletWebRequest#checkNotModified(long)), or a method argument that provides access to the response stream.

Authors
Rossen Stoyanchev, Juergen Hoeller
Since
3.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ServletInvocableHandlerMethod.ConcurrentResultHandlerMethod

A nested subclass of ServletInvocableHandlerMethod that uses a simple Callable instead of the original controller as the handler in order to return the fixed (concurrent) result value given to it.

private class
ServletInvocableHandlerMethod.ConcurrentResultMethodParameter

MethodParameter 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. Foo instead of DeferredResult<Foo>.

Field Summary

Modifier and TypeField and Description
private static final Method
private HandlerMethodReturnValueHandlerComposite

Constructor Summary

AccessConstructor and Description
public
ServletInvocableHandlerMethod(Object handler, Method method)

Creates an instance from the given handler and method.

public
ServletInvocableHandlerMethod(Object handler, Method method, MessageSource messageSource)

Variant of ServletInvocableHandlerMethod(Object, Method) that also accepts a MessageSource, e.g. to resolve @ResponseStatus messages with.

public
ServletInvocableHandlerMethod(HandlerMethod handlerMethod)

Create an instance from a HandlerMethod.

Method Summary

Modifier and TypeMethod and Description
private void
private String
public void
invokeAndHandle(ServletWebRequest
the current request
webRequest
,
ModelAndViewContainer
the ModelAndViewContainer for this request
mavContainer
,
Object...
"given" arguments matched by type (not resolved)
providedArgs
)

Invoke the method and handle the return value through one of the configured HandlerMethodReturnValueHandlers.

private boolean
isRequestNotModified(ServletWebRequest webRequest)

Does the given request qualify as "not modified"?

public void
setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)

Register HandlerMethodReturnValueHandler instances to use to handle return values.

private void
setResponseStatus(ServletWebRequest webRequest)

Set the response status according to the ResponseStatus annotation.

pack-priv ServletInvocableHandlerMethod
wrapConcurrentResult(Object result)

Create a nested ServletInvocableHandlerMethod subclass that returns the given value (or raises an Exception if the value is one) rather than actually invoking the controller method.

Inherited from org.springframework.web.method.support.InvocableHandlerMethod:
doInvokegetMethodArgumentValuesinvokeForRequestinvokeSuspendingFunctionsetDataBinderFactorysetHandlerMethodArgumentResolverssetMethodValidatorsetParameterNameDiscoverer

Field Detail

CALLABLE_METHODback to summary
private static final Method CALLABLE_METHOD
returnValueHandlersback to summary
private HandlerMethodReturnValueHandlerComposite returnValueHandlers
Annotations
@Nullable

Constructor Detail

ServletInvocableHandlerMethodback to summary
public ServletInvocableHandlerMethod(Object handler, Method method)

Creates an instance from the given handler and method.

ServletInvocableHandlerMethodback to summary
public ServletInvocableHandlerMethod(Object handler, Method method, MessageSource messageSource)

Variant of ServletInvocableHandlerMethod(Object, Method) that also accepts a MessageSource, e.g. to resolve @ResponseStatus messages with.

Since
5.3.10
ServletInvocableHandlerMethodback to summary
public ServletInvocableHandlerMethod(HandlerMethod handlerMethod)

Create an instance from a HandlerMethod.

Method Detail

disableContentCachingIfNecessaryback to summary
private void disableContentCachingIfNecessary(ServletWebRequest webRequest)
formatErrorForReturnValueback to summary
private String formatErrorForReturnValue(Object returnValue)
invokeAndHandleback to summary
public void invokeAndHandle(ServletWebRequest webRequest, ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception

Invoke the method and handle the return value through one of the configured HandlerMethodReturnValueHandlers.

Parameters
webRequest:ServletWebRequest

the current request

mavContainer:ModelAndViewContainer

the ModelAndViewContainer for this request

providedArgs:Object[]

"given" arguments matched by type (not resolved)

isRequestNotModifiedback to summary
private boolean isRequestNotModified(ServletWebRequest webRequest)

Does the given request qualify as "not modified"?

See Also
ServletWebRequest#checkNotModified(long), ServletWebRequest#checkNotModified(String)
setHandlerMethodReturnValueHandlersback to summary
public void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)

Register HandlerMethodReturnValueHandler instances to use to handle return values.

setResponseStatusback to summary
private void setResponseStatus(ServletWebRequest webRequest) throws IOException

Set the response status according to the ResponseStatus annotation.

wrapConcurrentResultback to summary
pack-priv ServletInvocableHandlerMethod wrapConcurrentResult(Object result)

Create a nested ServletInvocableHandlerMethod subclass that returns the given value (or raises an Exception if the value is one) rather than actually invoking the controller method. This is useful when processing async return values (e.g. Callable, DeferredResult, ListenableFuture).

org.springframework.web.servlet.mvc.method.annotation back to summary

private Class ServletInvocableHandlerMethod.ConcurrentResultHandlerMethod

extends ServletInvocableHandlerMethod
Class Inheritance

A nested subclass of ServletInvocableHandlerMethod that uses a simple Callable instead of the original controller as the handler in order to return the fixed (concurrent) result value given to it. Effectively "resumes" processing with the asynchronously produced return value.

Field Summary

Modifier and TypeField and Description
private final MethodParameter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Class<?>
getBeanType()

Overrides org.springframework.web.method.HandlerMethod.getBeanType.

Bridge to actual controller type-level annotations.

public <A extends Annotation> A
getMethodAnnotation(Class<A>
the annotation type to look for
annotationType
)

Overrides org.springframework.core.annotation.AnnotatedMethod.getMethodAnnotation.

Bridge to controller method-level annotations.

public MethodParameter
getReturnValueType(Object returnValue)

Overrides org.springframework.core.annotation.AnnotatedMethod.getReturnValueType.

Bridge to actual return value or generic type within the declared async return type, e.g. Foo instead of DeferredResult<Foo>.

public <A extends Annotation> boolean
hasMethodAnnotation(Class<A>
the annotation type to look for
annotationType
)

Overrides org.springframework.core.annotation.AnnotatedMethod.hasMethodAnnotation.

Bridge to controller method-level annotations.

Inherited from org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod:
invokeAndHandlesetHandlerMethodReturnValueHandlerswrapConcurrentResult

Field Detail

returnTypeback to summary
private final MethodParameter returnType

Constructor Detail

ConcurrentResultHandlerMethodback to summary
public ConcurrentResultHandlerMethod(Object result, ServletInvocableHandlerMethod.ConcurrentResultMethodParameter returnType)

Method Detail

getBeanTypeback to summary
public Class<?> getBeanType()

Overrides org.springframework.web.method.HandlerMethod.getBeanType.

Bridge to actual controller type-level annotations.

Annotations
@Override
getMethodAnnotationback to summary
public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType)

Overrides org.springframework.core.annotation.AnnotatedMethod.getMethodAnnotation.

Bridge to controller method-level annotations.

Parameters
annotationType:Class<A>

Doc from org.springframework.core.annotation.AnnotatedMethod.getMethodAnnotation.

the annotation type to look for

Returns:A

Doc from org.springframework.core.annotation.AnnotatedMethod.getMethodAnnotation.

the annotation, or null if none found

Annotations
@Override
getReturnValueTypeback to summary
public MethodParameter getReturnValueType(Object returnValue)

Overrides org.springframework.core.annotation.AnnotatedMethod.getReturnValueType.

Bridge to actual return value or generic type within the declared async return type, e.g. Foo instead of DeferredResult<Foo>.

Annotations
@Override
hasMethodAnnotationback to summary
public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType)

Overrides org.springframework.core.annotation.AnnotatedMethod.hasMethodAnnotation.

Bridge to controller method-level annotations.

Parameters
annotationType:Class<A>

Doc from org.springframework.core.annotation.AnnotatedMethod.hasMethodAnnotation.

the annotation type to look for

Annotations
@Override
org.springframework.web.servlet.mvc.method.annotation back to summary

private Class ServletInvocableHandlerMethod.ConcurrentResultMethodParameter

extends AnnotatedMethodParameter
Class Inheritance

MethodParameter 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. Foo instead of DeferredResult<Foo>.

Field Summary

Modifier and TypeField and Description
private final ResolvableType
private final Object

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public ServletInvocableHandlerMethod.ConcurrentResultMethodParameter
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.

public <T extends Annotation> boolean
hasMethodAnnotation(Class<T>
the annotation type to look for
annotationType
)

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

Return whether the method/constructor is annotated with the given type.

Inherited from org.springframework.core.annotation.AnnotatedMethod.AnnotatedMethodParameter:
getContainingClassgetMethodgetMethodAnnotationgetParameterAnnotations

Field Detail

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

Constructor Detail

ConcurrentResultMethodParameterback to summary
public ConcurrentResultMethodParameter(Object returnValue)
ConcurrentResultMethodParameterback to summary
public ConcurrentResultMethodParameter(ServletInvocableHandlerMethod.ConcurrentResultMethodParameter original)

Method Detail

cloneback to summary
public ServletInvocableHandlerMethod.ConcurrentResultMethodParameter 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:ServletInvocableHandlerMethod.ConcurrentResultMethodParameter

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
hasMethodAnnotationback to summary
public <T extends Annotation> boolean hasMethodAnnotation(Class<T> annotationType)

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

Doc from org.springframework.core.MethodParameter.hasMethodAnnotation.

Return whether the method/constructor is annotated with the given type.

Parameters
annotationType:Class<T>

the annotation type to look for

Annotations
@Override