public abstract class AbstractArgumentMethodArgumentResolver extends Object implements org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver
Subclasses only need to define specific steps such as how to obtain named value details from a method parameter, how to resolve to argument values, or how to handle missing values.
A default value string can contain ${...} placeholders and Spring
Expression Language #{...} expressions which will be resolved if a
ConfigurableBeanFactory is supplied to the class constructor.
A ConversionService is used to convert a resolved String argument
value to the expected target method parameter type.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractArgumentMethodArgumentResolver.NamedValueInfo
Represents a named value declaration.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
ARGUMENT_PREFIX |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractArgumentMethodArgumentResolver(org.springframework.core.convert.ConversionService conversionService,
org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)
Constructor with a
ConversionService and a BeanFactory. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract AbstractArgumentMethodArgumentResolver.NamedValueInfo |
createNamedValueInfo(org.springframework.core.MethodParameter parameter)
Create the
AbstractArgumentMethodArgumentResolver.NamedValueInfo object for the given method parameter. |
protected abstract void |
handleMissingValue(List<String> names,
org.springframework.core.MethodParameter parameter,
org.springframework.messaging.Message<?> message)
Invoked when a value is required, but
resolveArgumentInternal(org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>, java.util.List<java.lang.String>)
returned null and there is no default value. |
protected void |
handleResolvedValue(Object arg,
List<String> name,
org.springframework.core.MethodParameter parameter,
org.springframework.messaging.Message<?> message)
Invoked after a value is resolved.
|
Object |
resolveArgument(org.springframework.core.MethodParameter parameter,
org.springframework.messaging.Message<?> message) |
protected abstract Object |
resolveArgumentInternal(org.springframework.core.MethodParameter parameter,
org.springframework.messaging.Message<?> message,
List<String> names)
Resolves the given parameter type and value name into an argument value.
|
public static final String ARGUMENT_PREFIX
protected AbstractArgumentMethodArgumentResolver(org.springframework.core.convert.ConversionService conversionService,
@Nullable
org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)
ConversionService and a BeanFactory.conversionService - conversion service for converting String values
to the target method parameter typebeanFactory - a bean factory for resolving ${...}
placeholders and #{...} SpEL expressions in default valuespublic Object resolveArgument(org.springframework.core.MethodParameter parameter, org.springframework.messaging.Message<?> message) throws Exception
resolveArgument in interface org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverExceptionprotected abstract AbstractArgumentMethodArgumentResolver.NamedValueInfo createNamedValueInfo(org.springframework.core.MethodParameter parameter)
AbstractArgumentMethodArgumentResolver.NamedValueInfo object for the given method parameter.
Implementations typically retrieve the method annotation by means of
MethodParameter.getParameterAnnotation(Class).parameter - the method parameter@Nullable protected abstract Object resolveArgumentInternal(org.springframework.core.MethodParameter parameter, org.springframework.messaging.Message<?> message, List<String> names) throws Exception
parameter - the method parameter to resolve to an argument valuemessage - the current requestnames - the name of the values being resolvednullException - in case of errorsprotected abstract void handleMissingValue(List<String> names, org.springframework.core.MethodParameter parameter, org.springframework.messaging.Message<?> message)
resolveArgumentInternal(org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>, java.util.List<java.lang.String>)
returned null and there is no default value. Sub-classes can
throw an appropriate exception for this case.names - the name for the valueparameter - the target method parametermessage - the message being processedprotected void handleResolvedValue(@Nullable
Object arg,
List<String> name,
org.springframework.core.MethodParameter parameter,
org.springframework.messaging.Message<?> message)
arg - the resolved argument valuename - the argument nameparameter - the argument parameter typemessage - the messageCopyright © 2023. All rights reserved.