Class HandlerMethodReturnValueHandlerComposite
java.lang.Object
org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite
- All Implemented Interfaces:
HandlerMethodReturnValueHandler
public class HandlerMethodReturnValueHandlerComposite
extends Object
implements HandlerMethodReturnValueHandler
Handles method return values by delegating to a list of registered
HandlerMethodReturnValueHandlers.
Previously resolved return types are cached for faster lookups.- Since:
- 3.1
- Author:
- Rossen Stoyanchev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd the givenHandlerMethodReturnValueHandler.addHandlers(@Nullable List<? extends HandlerMethodReturnValueHandler> handlers) Add the givenHandlerMethodReturnValueHandlers.Return a read-only list with the registered handlers, or an empty list.voidhandleReturnValue(@Nullable Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativewebRequest webRequest) Iterate over registeredHandlerMethodReturnValueHandlersand invoke the one that supports it.booleansupportsReturnType(MethodParameter returnType) Whether the given method return type is supported by any registeredHandlerMethodReturnValueHandler.
-
Constructor Details
-
HandlerMethodReturnValueHandlerComposite
public HandlerMethodReturnValueHandlerComposite()
-
-
Method Details
-
getHandlers
Return a read-only list with the registered handlers, or an empty list. -
supportsReturnType
Whether the given method return type is supported by any registeredHandlerMethodReturnValueHandler.- Specified by:
supportsReturnTypein interfaceHandlerMethodReturnValueHandler- Parameters:
returnType- the method return type to check- Returns:
trueif this handler supports the supplied return type;falseotherwise
-
handleReturnValue
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativewebRequest webRequest) throws Exception Iterate over registeredHandlerMethodReturnValueHandlersand invoke the one that supports it.- Specified by:
handleReturnValuein interfaceHandlerMethodReturnValueHandler- Parameters:
returnValue- the value returned from the handler methodreturnType- the type of the return value. This type must have previously been passed toHandlerMethodReturnValueHandler.supportsReturnType(MethodParameter)which must have returnedtrue.mavContainer- the ModelAndViewContainer for the current requestwebRequest- the current request- Throws:
IllegalStateException- if no suitableHandlerMethodReturnValueHandleris found.Exception- if the return value handling results in an error
-
addHandler
Add the givenHandlerMethodReturnValueHandler. -
addHandlers
public HandlerMethodReturnValueHandlerComposite addHandlers(@Nullable List<? extends HandlerMethodReturnValueHandler> handlers) Add the givenHandlerMethodReturnValueHandlers.
-