public class HandlerMethodInvoker
extends java.lang.Object
HandlerMethodResolver
for a specific handler type.
Used by AnnotationMethodHandlerAdapter
and AnnotationMethodHandlerAdapter
.
invokeHandlerMethod(java.lang.reflect.Method, java.lang.Object, org.springframework.web.context.request.NativeWebRequest, org.springframework.ui.ExtendedModelMap)
Modifier and Type | Field and Description |
---|---|
private WebBindingInitializer |
bindingInitializer |
private WebArgumentResolver[] |
customArgumentResolvers |
private static Log |
logger
We'll create a lot of these objects, so we don't want a new logger every time.
|
private HttpMessageConverter<?>[] |
messageConverters |
private HandlerMethodResolver |
methodResolver |
private static java.lang.String |
MODEL_KEY_PREFIX_STALE |
private ParameterNameDiscoverer |
parameterNameDiscoverer |
private SessionAttributeStore |
sessionAttributeStore |
private SimpleSessionStatus |
sessionStatus |
Constructor and Description |
---|
HandlerMethodInvoker(HandlerMethodResolver methodResolver) |
HandlerMethodInvoker(HandlerMethodResolver methodResolver,
WebBindingInitializer bindingInitializer) |
HandlerMethodInvoker(HandlerMethodResolver methodResolver,
WebBindingInitializer bindingInitializer,
SessionAttributeStore sessionAttributeStore,
ParameterNameDiscoverer parameterNameDiscoverer,
WebArgumentResolver[] customArgumentResolvers,
HttpMessageConverter<?>[] messageConverters) |
Modifier and Type | Method and Description |
---|---|
protected void |
addReturnValueAsModelAttribute(java.lang.reflect.Method handlerMethod,
java.lang.Class<?> handlerType,
java.lang.Object returnValue,
ExtendedModelMap implicitModel) |
private java.lang.Object |
checkValue(java.lang.String name,
java.lang.Object value,
java.lang.Class<?> paramType) |
protected WebDataBinder |
createBinder(NativeWebRequest webRequest,
java.lang.Object target,
java.lang.String objectName) |
protected HttpInputMessage |
createHttpInputMessage(NativeWebRequest webRequest)
Return a
HttpInputMessage for the given NativeWebRequest . |
protected HttpOutputMessage |
createHttpOutputMessage(NativeWebRequest webRequest)
Return a
HttpOutputMessage for the given NativeWebRequest . |
protected void |
doBind(WebDataBinder binder,
NativeWebRequest webRequest) |
private void |
doBind(WebDataBinder binder,
NativeWebRequest webRequest,
boolean validate,
java.lang.Object[] validationHints,
boolean failOnErrors) |
private java.lang.Class<?> |
getHttpEntityType(MethodParameter methodParam) |
private java.lang.String |
getRequiredParameterName(MethodParameter methodParam) |
protected void |
initBinder(java.lang.Object handler,
java.lang.String attrName,
WebDataBinder binder,
NativeWebRequest webRequest) |
java.lang.Object |
invokeHandlerMethod(java.lang.reflect.Method handlerMethod,
java.lang.Object handler,
NativeWebRequest webRequest,
ExtendedModelMap implicitModel) |
protected boolean |
isBindingCandidate(java.lang.Object value)
Determine whether the given value qualifies as a "binding candidate", i.e.
|
protected java.lang.String |
parseDefaultValueAttribute(java.lang.String value) |
protected void |
raiseMissingCookieException(java.lang.String cookieName,
java.lang.Class<?> paramType) |
protected void |
raiseMissingHeaderException(java.lang.String headerName,
java.lang.Class<?> paramType) |
protected void |
raiseMissingParameterException(java.lang.String paramName,
java.lang.Class<?> paramType) |
protected void |
raiseSessionRequiredException(java.lang.String message) |
private java.lang.Object |
readWithMessageConverters(MethodParameter methodParam,
HttpInputMessage inputMessage,
java.lang.Class<?> paramType) |
protected java.lang.Object |
resolveCommonArgument(MethodParameter methodParameter,
NativeWebRequest webRequest) |
private java.lang.Object |
resolveCookieValue(java.lang.String cookieName,
boolean required,
java.lang.String defaultValue,
MethodParameter methodParam,
NativeWebRequest webRequest,
java.lang.Object handlerForInitBinderCall) |
protected java.lang.Object |
resolveCookieValue(java.lang.String cookieName,
java.lang.Class<?> paramType,
NativeWebRequest webRequest)
Resolves the given
@CookieValue annotation. |
protected java.lang.Object |
resolveDefaultValue(java.lang.String value) |
private java.lang.Object[] |
resolveHandlerArguments(java.lang.reflect.Method handlerMethod,
java.lang.Object handler,
NativeWebRequest webRequest,
ExtendedModelMap implicitModel) |
private HttpEntity<?> |
resolveHttpEntityRequest(MethodParameter methodParam,
NativeWebRequest webRequest) |
private java.lang.Object[] |
resolveInitBinderArguments(java.lang.Object handler,
java.lang.reflect.Method initBinderMethod,
WebDataBinder binder,
NativeWebRequest webRequest) |
private WebDataBinder |
resolveModelAttribute(java.lang.String attrName,
MethodParameter methodParam,
ExtendedModelMap implicitModel,
NativeWebRequest webRequest,
java.lang.Object handler) |
protected java.lang.String |
resolvePathVariable(java.lang.String pathVarName,
java.lang.Class<?> paramType,
NativeWebRequest webRequest)
Resolves the given
@PathVariable annotation. |
private java.lang.Object |
resolvePathVariable(java.lang.String pathVarName,
MethodParameter methodParam,
NativeWebRequest webRequest,
java.lang.Object handlerForInitBinderCall) |
protected java.lang.Object |
resolveRequestBody(MethodParameter methodParam,
NativeWebRequest webRequest,
java.lang.Object handler)
Resolves the given
@RequestBody annotation. |
private java.lang.Object |
resolveRequestHeader(java.lang.String headerName,
boolean required,
java.lang.String defaultValue,
MethodParameter methodParam,
NativeWebRequest webRequest,
java.lang.Object handlerForInitBinderCall) |
private java.util.Map<java.lang.String,?> |
resolveRequestHeaderMap(java.lang.Class<? extends java.util.Map<?,?>> mapType,
NativeWebRequest webRequest) |
private java.lang.Object |
resolveRequestParam(java.lang.String paramName,
boolean required,
java.lang.String defaultValue,
MethodParameter methodParam,
NativeWebRequest webRequest,
java.lang.Object handlerForInitBinderCall) |
private java.util.Map<java.lang.String,?> |
resolveRequestParamMap(java.lang.Class<? extends java.util.Map<?,?>> mapType,
NativeWebRequest webRequest) |
protected java.lang.Object |
resolveStandardArgument(java.lang.Class<?> parameterType,
NativeWebRequest webRequest) |
void |
updateModelAttributes(java.lang.Object handler,
java.util.Map<java.lang.String,java.lang.Object> mavModel,
ExtendedModelMap implicitModel,
NativeWebRequest webRequest) |
private static final java.lang.String MODEL_KEY_PREFIX_STALE
private static final Log logger
private final HandlerMethodResolver methodResolver
private final WebBindingInitializer bindingInitializer
private final SessionAttributeStore sessionAttributeStore
private final ParameterNameDiscoverer parameterNameDiscoverer
private final WebArgumentResolver[] customArgumentResolvers
private final HttpMessageConverter<?>[] messageConverters
private final SimpleSessionStatus sessionStatus
public HandlerMethodInvoker(HandlerMethodResolver methodResolver)
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer)
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer, SessionAttributeStore sessionAttributeStore, ParameterNameDiscoverer parameterNameDiscoverer, WebArgumentResolver[] customArgumentResolvers, HttpMessageConverter<?>[] messageConverters)
public final java.lang.Object invokeHandlerMethod(java.lang.reflect.Method handlerMethod, java.lang.Object handler, NativeWebRequest webRequest, ExtendedModelMap implicitModel) throws java.lang.Exception
java.lang.Exception
public final void updateModelAttributes(java.lang.Object handler, java.util.Map<java.lang.String,java.lang.Object> mavModel, ExtendedModelMap implicitModel, NativeWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
private java.lang.Object[] resolveHandlerArguments(java.lang.reflect.Method handlerMethod, java.lang.Object handler, NativeWebRequest webRequest, ExtendedModelMap implicitModel) throws java.lang.Exception
java.lang.Exception
protected void initBinder(java.lang.Object handler, java.lang.String attrName, WebDataBinder binder, NativeWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
private java.lang.Object[] resolveInitBinderArguments(java.lang.Object handler, java.lang.reflect.Method initBinderMethod, WebDataBinder binder, NativeWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
private java.lang.Object resolveRequestParam(java.lang.String paramName, boolean required, java.lang.String defaultValue, MethodParameter methodParam, NativeWebRequest webRequest, java.lang.Object handlerForInitBinderCall) throws java.lang.Exception
java.lang.Exception
private java.util.Map<java.lang.String,?> resolveRequestParamMap(java.lang.Class<? extends java.util.Map<?,?>> mapType, NativeWebRequest webRequest)
private java.lang.Object resolveRequestHeader(java.lang.String headerName, boolean required, java.lang.String defaultValue, MethodParameter methodParam, NativeWebRequest webRequest, java.lang.Object handlerForInitBinderCall) throws java.lang.Exception
java.lang.Exception
private java.util.Map<java.lang.String,?> resolveRequestHeaderMap(java.lang.Class<? extends java.util.Map<?,?>> mapType, NativeWebRequest webRequest)
protected java.lang.Object resolveRequestBody(MethodParameter methodParam, NativeWebRequest webRequest, java.lang.Object handler) throws java.lang.Exception
@RequestBody
annotation.java.lang.Exception
private HttpEntity<?> resolveHttpEntityRequest(MethodParameter methodParam, NativeWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
private java.lang.Object readWithMessageConverters(MethodParameter methodParam, HttpInputMessage inputMessage, java.lang.Class<?> paramType) throws java.lang.Exception
java.lang.Exception
private java.lang.Class<?> getHttpEntityType(MethodParameter methodParam)
private java.lang.Object resolveCookieValue(java.lang.String cookieName, boolean required, java.lang.String defaultValue, MethodParameter methodParam, NativeWebRequest webRequest, java.lang.Object handlerForInitBinderCall) throws java.lang.Exception
java.lang.Exception
protected java.lang.Object resolveCookieValue(java.lang.String cookieName, java.lang.Class<?> paramType, NativeWebRequest webRequest) throws java.lang.Exception
@CookieValue
annotation.
Throws an UnsupportedOperationException by default.
java.lang.Exception
private java.lang.Object resolvePathVariable(java.lang.String pathVarName, MethodParameter methodParam, NativeWebRequest webRequest, java.lang.Object handlerForInitBinderCall) throws java.lang.Exception
java.lang.Exception
protected java.lang.String resolvePathVariable(java.lang.String pathVarName, java.lang.Class<?> paramType, NativeWebRequest webRequest) throws java.lang.Exception
@PathVariable
annotation.
Throws an UnsupportedOperationException by default.
java.lang.Exception
private java.lang.String getRequiredParameterName(MethodParameter methodParam)
private java.lang.Object checkValue(java.lang.String name, java.lang.Object value, java.lang.Class<?> paramType)
private WebDataBinder resolveModelAttribute(java.lang.String attrName, MethodParameter methodParam, ExtendedModelMap implicitModel, NativeWebRequest webRequest, java.lang.Object handler) throws java.lang.Exception
java.lang.Exception
protected boolean isBindingCandidate(java.lang.Object value)
protected void raiseMissingParameterException(java.lang.String paramName, java.lang.Class<?> paramType) throws java.lang.Exception
java.lang.Exception
protected void raiseMissingHeaderException(java.lang.String headerName, java.lang.Class<?> paramType) throws java.lang.Exception
java.lang.Exception
protected void raiseMissingCookieException(java.lang.String cookieName, java.lang.Class<?> paramType) throws java.lang.Exception
java.lang.Exception
protected void raiseSessionRequiredException(java.lang.String message) throws java.lang.Exception
java.lang.Exception
protected WebDataBinder createBinder(NativeWebRequest webRequest, java.lang.Object target, java.lang.String objectName) throws java.lang.Exception
java.lang.Exception
private void doBind(WebDataBinder binder, NativeWebRequest webRequest, boolean validate, java.lang.Object[] validationHints, boolean failOnErrors) throws java.lang.Exception
java.lang.Exception
protected void doBind(WebDataBinder binder, NativeWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
protected HttpInputMessage createHttpInputMessage(NativeWebRequest webRequest) throws java.lang.Exception
HttpInputMessage
for the given NativeWebRequest
.
Throws an UnsupportedOperation1Exception by default.
java.lang.Exception
protected HttpOutputMessage createHttpOutputMessage(NativeWebRequest webRequest) throws java.lang.Exception
HttpOutputMessage
for the given NativeWebRequest
.
Throws an UnsupportedOperationException by default.
java.lang.Exception
protected java.lang.String parseDefaultValueAttribute(java.lang.String value)
protected java.lang.Object resolveDefaultValue(java.lang.String value)
protected java.lang.Object resolveCommonArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
protected java.lang.Object resolveStandardArgument(java.lang.Class<?> parameterType, NativeWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
protected final void addReturnValueAsModelAttribute(java.lang.reflect.Method handlerMethod, java.lang.Class<?> handlerType, java.lang.Object returnValue, ExtendedModelMap implicitModel)