Class AbstractArgumentMethodArgumentResolver
java.lang.Object
org.springframework.shell.support.AbstractArgumentMethodArgumentResolver
- All Implemented Interfaces:
org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver
- Direct Known Subclasses:
ArgumentHeaderMethodArgumentResolver
,ShellOptionMethodArgumentResolver
public abstract class AbstractArgumentMethodArgumentResolver
extends Object
implements org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver
Abstract base class to resolve method arguments from a named value, e.g.
message headers or destination variables. Named values could have one or more
of a name, a required flag, and a default value.
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Represents a named value declaration. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractArgumentMethodArgumentResolver
(org.springframework.core.convert.ConversionService conversionService, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory) Constructor with aConversionService
and aBeanFactory
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractArgumentMethodArgumentResolver.NamedValueInfo
createNamedValueInfo
(org.springframework.core.MethodParameter parameter) Create theAbstractArgumentMethodArgumentResolver.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, butresolveArgumentInternal(org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>, java.util.List<java.lang.String>)
returnednull
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.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver
supportsParameter
-
Field Details
-
ARGUMENT_PREFIX
- See Also:
-
-
Constructor Details
-
AbstractArgumentMethodArgumentResolver
protected AbstractArgumentMethodArgumentResolver(org.springframework.core.convert.ConversionService conversionService, @Nullable org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory) Constructor with aConversionService
and aBeanFactory
.- Parameters:
conversionService
- conversion service for converting String values to the target method parameter typebeanFactory
- a bean factory for resolving${...}
placeholders and#{...}
SpEL expressions in default values
-
-
Method Details
-
resolveArgument
public Object resolveArgument(org.springframework.core.MethodParameter parameter, org.springframework.messaging.Message<?> message) throws Exception - Specified by:
resolveArgument
in interfaceorg.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver
- Throws:
Exception
-
createNamedValueInfo
protected abstract AbstractArgumentMethodArgumentResolver.NamedValueInfo createNamedValueInfo(org.springframework.core.MethodParameter parameter) Create theAbstractArgumentMethodArgumentResolver.NamedValueInfo
object for the given method parameter. Implementations typically retrieve the method annotation by means ofMethodParameter.getParameterAnnotation(Class)
.- Parameters:
parameter
- the method parameter- Returns:
- the named value information
-
resolveArgumentInternal
@Nullable protected abstract Object resolveArgumentInternal(org.springframework.core.MethodParameter parameter, org.springframework.messaging.Message<?> message, List<String> names) throws Exception Resolves the given parameter type and value name into an argument value.- Parameters:
parameter
- the method parameter to resolve to an argument valuemessage
- the current requestnames
- the name of the values being resolved- Returns:
- the resolved argument. May be
null
- Throws:
Exception
- in case of errors
-
handleMissingValue
protected abstract void handleMissingValue(List<String> names, org.springframework.core.MethodParameter parameter, org.springframework.messaging.Message<?> message) Invoked when a value is required, butresolveArgumentInternal(org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>, java.util.List<java.lang.String>)
returnednull
and there is no default value. Sub-classes can throw an appropriate exception for this case.- Parameters:
names
- the name for the valueparameter
- the target method parametermessage
- the message being processed
-
handleResolvedValue
protected void handleResolvedValue(@Nullable Object arg, List<String> name, org.springframework.core.MethodParameter parameter, org.springframework.messaging.Message<?> message) Invoked after a value is resolved.- Parameters:
arg
- the resolved argument valuename
- the argument nameparameter
- the argument parameter typemessage
- the message
-