org.springframework.messaging.handler.annotation.reactive

## Class AbstractNamedValueMethodArgumentResolver

- java.lang.Object
- - org.springframework.messaging.handler.annotation.reactive.AbstractNamedValueMethodArgumentResolver

All Implemented Interfaces:
  HandlerMethodArgumentResolver, SyncHandlerMethodArgumentResolver

Direct Known Subclasses:
  DestinationVariableMethodArgumentResolver, HeaderMethodArgumentResolver

    public abstract class AbstractNamedValueMethodArgumentResolver
    extends Object
    implements SyncHandlerMethodArgumentResolver

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.

Since:
  5.2
Author:
  Rossen Stoyanchev

### Nested Class Summary

Nested Classes
`protected static class` `AbstractNamedValueMethodArgumentResolver.NamedValueInfo` Represents a named value declaration.

### Constructor Summary

Constructors
`protected` `AbstractNamedValueMethodArgumentResolver(org.springframework.core.convert.ConversionService conversionService, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)` Constructor with a `ConversionService` and a `BeanFactory`.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected abstract AbstractNamedValueMethodArgumentResolver.NamedValueInfo` `createNamedValueInfo(org.springframework.core.MethodParameter parameter)` Create the `AbstractNamedValueMethodArgumentResolver.NamedValueInfo` object for the given method parameter.
`protected abstract void` `handleMissingValue(String name, org.springframework.core.MethodParameter parameter, Message<?> message)` Invoked when a value is required, but `resolveArgumentInternal(org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>, java.lang.String)` returned `null` and there is no default value.
`protected abstract Object` `resolveArgumentInternal(org.springframework.core.MethodParameter parameter, Message<?> message, String name)` Resolves the given parameter type and value name into an argument value.
`Object` `resolveArgumentValue(org.springframework.core.MethodParameter parameter, Message<?> message)` Resolve the value for the method parameter synchronously.

### 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.reactive.SyncHandlerMethodArgumentResolver

`resolveArgument`

### Methods inherited from interface org.springframework.messaging.handler.invocation.reactive.HandlerMethodArgumentResolver

`supportsParameter`

### Constructor Detail

#### AbstractNamedValueMethodArgumentResolver

    protected AbstractNamedValueMethodArgumentResolver(org.springframework.core.convert.ConversionService conversionService,
                                                       @Nullable
                                                       org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)

Constructor with a `ConversionService` and a `BeanFactory`.

Parameters:
  `conversionService` - conversion service for converting String values to the target method parameter type
  `beanFactory` - a bean factory for resolving `${...}` placeholders and `#{...}` SpEL expressions in default values

### Method Detail

#### resolveArgumentValue

    public Object resolveArgumentValue(org.springframework.core.MethodParameter parameter,
                                       Message<?> message)

Description copied from interface: `SyncHandlerMethodArgumentResolver`
Resolve the value for the method parameter synchronously.

Specified by:
  `resolveArgumentValue` in interface `SyncHandlerMethodArgumentResolver`
Parameters:
  `parameter` - the method parameter
  `message` - the currently processed message
Returns:
  the resolved value, if any

#### createNamedValueInfo

    protected abstract AbstractNamedValueMethodArgumentResolver.NamedValueInfo createNamedValueInfo(org.springframework.core.MethodParameter parameter)

Create the `AbstractNamedValueMethodArgumentResolver.NamedValueInfo` object for the given method parameter. Implementations typically retrieve the method annotation by means of `MethodParameter.getParameterAnnotation(Class)`.

Parameters:
  `parameter` - the method parameter
Returns:
  the named value information

#### resolveArgumentInternal

    @Nullable
    protected abstract Object resolveArgumentInternal(org.springframework.core.MethodParameter parameter,
                                                                Message<?> message,
                                                                String name)

Resolves the given parameter type and value name into an argument value.

Parameters:
  `parameter` - the method parameter to resolve to an argument value
  `message` - the current request
  `name` - the name of the value being resolved
Returns:
  the resolved argument. May be `null`

#### handleMissingValue

    protected abstract void handleMissingValue(String name,
                                               org.springframework.core.MethodParameter parameter,
                                               Message<?> message)

Invoked when a value is required, but `resolveArgumentInternal(org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>, java.lang.String)` returned `null` and there is no default value. Sub-classes can throw an appropriate exception for this case.

Parameters:
  `name` - the name for the value
  `parameter` - the target method parameter
  `message` - the message being processed