Package io.microsphere.spring.web.util
Class RequestAttributesUtils
- java.lang.Object
-
- io.microsphere.spring.web.util.RequestAttributesUtils
-
public abstract class RequestAttributesUtils extends java.lang.ObjectRequestAttributesUtilities Class- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
RequestAttributesUtils
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringHANDLER_METHOD_ARGUMENTS_ATTRIBUTE_NAME_PREFIXThe prefix of the attribute name of theHandlerMethodmethod parameterstatic java.lang.StringHANDLER_METHOD_REQUEST_BODY_ARGUMENT_ATTRIBUTE_NAME_PREFIXThe prefix of the attribute name of theHandlerMethodmethod parameter annotatedResponseBodystatic java.lang.StringHANDLER_METHOD_RETURN_VALUE_ATTRIBUTE_NAME_PREFIXThe prefix of the attribute name of theHandlerMethodmethod return value
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object[]getHandlerMethodArguments(java.lang.reflect.Method method)Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()static java.lang.Object[]getHandlerMethodArguments(org.springframework.core.MethodParameter parameter)Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()static java.lang.Object[]getHandlerMethodArguments(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method)Gets theHandlerMethodmethod parameterstatic java.lang.Object[]getHandlerMethodArguments(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.core.MethodParameter parameter)Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()static java.lang.Object[]getHandlerMethodArguments(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.web.method.HandlerMethod handlerMethod)Gets theHandlerMethodmethod parameterstatic java.lang.Object[]getHandlerMethodArguments(org.springframework.web.method.HandlerMethod handlerMethod)Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()static <T> TgetHandlerMethodRequestBodyArgument(java.lang.reflect.Method method)Gets the@RequestBodymethod parameter from theRequestContextHolder.getRequestAttributes()static <T> TgetHandlerMethodRequestBodyArgument(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method)Gets the@RequestBodymethod parameter from theRequestAttributesstatic <T> TgetHandlerMethodRequestBodyArgument(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.web.method.HandlerMethod handlerMethod)Gets the@RequestBodymethod parameter from theRequestAttributesstatic <T> TgetHandlerMethodRequestBodyArgument(org.springframework.web.method.HandlerMethod handlerMethod)Gets the@RequestBodymethod parameter from theRequestContextHolder.getRequestAttributes()static <T> TgetHandlerMethodReturnValue(java.lang.reflect.Method method)Gets the value returned by theHandlerMethodmethod from theRequestContextHolder.getRequestAttributes()static <T> TgetHandlerMethodReturnValue(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method)Gets the value returned by theHandlerMethodmethodstatic <T> TgetHandlerMethodReturnValue(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.web.method.HandlerMethod handlerMethod)Gets the value returned by theHandlerMethodmethodstatic <T> TgetHandlerMethodReturnValue(org.springframework.web.method.HandlerMethod handlerMethod)Gets the value returned by theHandlerMethodmethod from theRequestContextHolder.getRequestAttributes()static <T> TgetRequestAttribute(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String attributeName)Get an attribute from theRequestAttributeswith the specified name.static voidsetHandlerMethodRequestBodyArgument(java.lang.reflect.Method method, java.lang.Object requestBodyArgument)Set the@RequestBodymethod parameter inHandlerMethodto theRequestAttributesstatic voidsetHandlerMethodRequestBodyArgument(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method, java.lang.Object requestBodyArgument)Set the@RequestBodymethod parameter inHandlerMethodto theRequestAttributesstatic voidsetHandlerMethodReturnValue(java.lang.reflect.Method method, java.lang.Object returnValue)Set theHandlerMethodmethod return value to theRequestContextHolder.getRequestAttributes()static voidsetHandlerMethodReturnValue(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method, java.lang.Object returnValue)Set theHandlerMethodmethod return value to theRequestAttributesstatic voidsetRequestAttribute(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String attributeName, java.lang.Object attributeValue)Set an attribute to theRequestAttributeswith the specified name and value.
-
-
-
Field Detail
-
HANDLER_METHOD_ARGUMENTS_ATTRIBUTE_NAME_PREFIX
public static final java.lang.String HANDLER_METHOD_ARGUMENTS_ATTRIBUTE_NAME_PREFIX
The prefix of the attribute name of theHandlerMethodmethod parameter- See Also:
- Constant Field Values
-
HANDLER_METHOD_REQUEST_BODY_ARGUMENT_ATTRIBUTE_NAME_PREFIX
public static final java.lang.String HANDLER_METHOD_REQUEST_BODY_ARGUMENT_ATTRIBUTE_NAME_PREFIX
The prefix of the attribute name of theHandlerMethodmethod parameter annotatedResponseBody- See Also:
- Constant Field Values
-
HANDLER_METHOD_RETURN_VALUE_ATTRIBUTE_NAME_PREFIX
public static final java.lang.String HANDLER_METHOD_RETURN_VALUE_ATTRIBUTE_NAME_PREFIX
The prefix of the attribute name of theHandlerMethodmethod return value- See Also:
- Constant Field Values
-
-
Method Detail
-
setRequestAttribute
public static void setRequestAttribute(@Nonnull org.springframework.web.context.request.RequestAttributes requestAttributes, @Nullable java.lang.String attributeName, @Nullable java.lang.Object attributeValue)Set an attribute to theRequestAttributeswith the specified name and value.- Parameters:
requestAttributes- theRequestAttributesto set the attributeattributeName- the name of the attribute to setattributeValue- the value of the attribute to set
-
getRequestAttribute
@Nullable public static <T> T getRequestAttribute(@Nonnull org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String attributeName)Get an attribute from theRequestAttributeswith the specified name.- Type Parameters:
T- the type of the attribute- Parameters:
requestAttributes- theRequestAttributesto get the attribute fromattributeName- the name of the attribute to get- Returns:
- the attribute value, or
nullif not found - Throws:
java.lang.IllegalArgumentException- if theRequestAttributesor attributeName is null
-
setHandlerMethodRequestBodyArgument
public static void setHandlerMethodRequestBodyArgument(java.lang.reflect.Method method, java.lang.Object requestBodyArgument)Set the@RequestBodymethod parameter inHandlerMethodto theRequestAttributes- Parameters:
method- HandlerMethodrequestBodyArgument-@RequestBodyThe method parameters
-
setHandlerMethodRequestBodyArgument
public static void setHandlerMethodRequestBodyArgument(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method, java.lang.Object requestBodyArgument)Set the@RequestBodymethod parameter inHandlerMethodto theRequestAttributes- Parameters:
requestAttributes-RequestAttributesmethod- HandlerMethodrequestBodyArgument-@RequestBodyThe method parameters
-
getHandlerMethodRequestBodyArgument
@Nullable public static <T> T getHandlerMethodRequestBodyArgument(org.springframework.web.method.HandlerMethod handlerMethod)
Gets the@RequestBodymethod parameter from theRequestContextHolder.getRequestAttributes()- Type Parameters:
T-@RequestBodyMethod parameter Types- Parameters:
handlerMethod-HandlerMethod- Returns:
@RequestBodyMethod parameters if present, otherwise,null
-
getHandlerMethodRequestBodyArgument
@Nullable public static <T> T getHandlerMethodRequestBodyArgument(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.web.method.HandlerMethod handlerMethod)Gets the@RequestBodymethod parameter from theRequestAttributes- Type Parameters:
T-@RequestBodyMethod parameter Types- Parameters:
requestAttributes-RequestAttributeshandlerMethod-HandlerMethod- Returns:
@RequestBodyMethod parameters if present, otherwise,null
-
getHandlerMethodRequestBodyArgument
@Nullable public static <T> T getHandlerMethodRequestBodyArgument(java.lang.reflect.Method method)
Gets the@RequestBodymethod parameter from theRequestContextHolder.getRequestAttributes()- Type Parameters:
T-@RequestBodyMethod parameter Types- Parameters:
method- HandlerMethod- Returns:
@RequestBodymethod parameter if present, otherwisenull
-
getHandlerMethodRequestBodyArgument
@Nullable public static <T> T getHandlerMethodRequestBodyArgument(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method)Gets the@RequestBodymethod parameter from theRequestAttributes- Type Parameters:
T-@RequestBodyMethod parameter Types- Parameters:
requestAttributes-RequestAttributesmethod- HandlerMethod- Returns:
@RequestBodymethod parameter if present, otherwisenull
-
getHandlerMethodArguments
@Nonnull public static java.lang.Object[] getHandlerMethodArguments(org.springframework.web.method.HandlerMethod handlerMethod)
Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()- Parameters:
handlerMethod-HandlerMethod- Returns:
- non-null
-
getHandlerMethodArguments
@Nonnull public static java.lang.Object[] getHandlerMethodArguments(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.web.method.HandlerMethod handlerMethod)Gets theHandlerMethodmethod parameter- Parameters:
requestAttributes-RequestAttributeshandlerMethod-HandlerMethod- Returns:
- non-null
-
getHandlerMethodArguments
@Nonnull public static java.lang.Object[] getHandlerMethodArguments(org.springframework.core.MethodParameter parameter)
Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()- Parameters:
parameter-MethodParameter- Returns:
- non-null
-
getHandlerMethodArguments
@Nonnull public static java.lang.Object[] getHandlerMethodArguments(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.core.MethodParameter parameter)Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()- Parameters:
requestAttributes-RequestAttributesparameter-MethodParameter- Returns:
- non-null
-
getHandlerMethodArguments
@Nonnull public static java.lang.Object[] getHandlerMethodArguments(java.lang.reflect.Method method)
Gets theHandlerMethodmethod parameter from theRequestContextHolder.getRequestAttributes()- Parameters:
method-Method- Returns:
- non-null
-
getHandlerMethodArguments
@Nonnull public static java.lang.Object[] getHandlerMethodArguments(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method)Gets theHandlerMethodmethod parameter- Parameters:
requestAttributes-RequestAttributesmethod-Method- Returns:
- non-null
-
setHandlerMethodReturnValue
public static void setHandlerMethodReturnValue(java.lang.reflect.Method method, java.lang.Object returnValue)Set theHandlerMethodmethod return value to theRequestContextHolder.getRequestAttributes()- Parameters:
method-MethodreturnValue- Method return value
-
setHandlerMethodReturnValue
public static void setHandlerMethodReturnValue(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method, java.lang.Object returnValue)Set theHandlerMethodmethod return value to theRequestAttributes- Parameters:
requestAttributes-RequestAttributesmethod-MethodreturnValue- Method return value
-
getHandlerMethodReturnValue
@Nullable public static <T> T getHandlerMethodReturnValue(org.springframework.web.method.HandlerMethod handlerMethod)
Gets the value returned by theHandlerMethodmethod from theRequestContextHolder.getRequestAttributes()- Type Parameters:
T- Method return value type- Parameters:
handlerMethod-HandlerMethod- Returns:
HandlerMethodMethod return value
-
getHandlerMethodReturnValue
@Nullable public static <T> T getHandlerMethodReturnValue(org.springframework.web.context.request.RequestAttributes requestAttributes, org.springframework.web.method.HandlerMethod handlerMethod)Gets the value returned by theHandlerMethodmethod- Type Parameters:
T- Method return value type- Parameters:
requestAttributes-RequestAttributeshandlerMethod-HandlerMethod- Returns:
HandlerMethodMethod return value
-
getHandlerMethodReturnValue
@Nullable public static <T> T getHandlerMethodReturnValue(java.lang.reflect.Method method)
Gets the value returned by theHandlerMethodmethod from theRequestContextHolder.getRequestAttributes()- Type Parameters:
T- Method return value type- Parameters:
method-Method- Returns:
HandlerMethodMethod return value
-
getHandlerMethodReturnValue
@Nullable public static <T> T getHandlerMethodReturnValue(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.reflect.Method method)Gets the value returned by theHandlerMethodmethod- Type Parameters:
T- Method return value type- Parameters:
requestAttributes-RequestAttributesmethod-Method- Returns:
HandlerMethodMethod return value
-
-