org.springframework.web.reactive.handler

## Class AbstractHandlerMapping

- java.lang.Object
- - org.springframework.context.support.ApplicationObjectSupport
  - - org.springframework.web.reactive.handler.AbstractHandlerMapping

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, HandlerMapping

Direct Known Subclasses:
  AbstractHandlerMethodMapping, AbstractUrlHandlerMapping, RouterFunctionMapping

    public abstract class AbstractHandlerMapping
    extends org.springframework.context.support.ApplicationObjectSupport
    implements HandlerMapping, org.springframework.core.Ordered, org.springframework.beans.factory.BeanNameAware

Abstract base class for `HandlerMapping` implementations.

Since:
  5.0
Author:
  Rossen Stoyanchev, Juergen Hoeller, Brian Clozel

### Field Summary

### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

`logger`

### Fields inherited from interface org.springframework.web.reactive.HandlerMapping

`BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

### Constructor Summary

Constructors
Constructor and Description
`AbstractHandlerMapping()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected String` `formatMappingName()`
`protected org.springframework.web.cors.CorsConfiguration` `getCorsConfiguration(Object handler, org.springframework.web.server.ServerWebExchange exchange)` Retrieve the CORS configuration for the given handler.
`org.springframework.web.cors.reactive.CorsProcessor` `getCorsProcessor()` Return the configured `CorsProcessor`.
`reactor.core.publisher.Mono<Object>` `getHandler(org.springframework.web.server.ServerWebExchange exchange)` Return a handler for this request.
`protected abstract reactor.core.publisher.Mono<?>` `getHandlerInternal(org.springframework.web.server.ServerWebExchange exchange)` Look up a handler for the given request, returning an empty `Mono` if no specific one is found.
`int` `getOrder()`
`org.springframework.web.util.pattern.PathPatternParser` `getPathPatternParser()` Return the `PathPatternParser` instance that is used for `CORS configuration checks`.
`protected boolean` `hasCorsConfigurationSource(Object handler)` Return `true` if there is a `CorsConfigurationSource` for this handler.
`void` `setBeanName(String name)`
`void` `setCorsConfigurations(Map<String,org.springframework.web.cors.CorsConfiguration> corsConfigurations)` Set the "global" CORS configurations based on URL patterns.
`void` `setCorsConfigurationSource(org.springframework.web.cors.reactive.CorsConfigurationSource corsConfigurationSource)` Set the "global" CORS configuration source.
`void` `setCorsProcessor(org.springframework.web.cors.reactive.CorsProcessor corsProcessor)` Configure a custom `CorsProcessor` to use to apply the matched `CorsConfiguration` for a request.
`void` `setOrder(int order)` Specify the order value for this HandlerMapping bean.
`void` `setUseCaseSensitiveMatch(boolean caseSensitiveMatch)` Shortcut method for setting the same property on the underlying pattern parser in use.
`void` `setUseTrailingSlashMatch(boolean trailingSlashMatch)` Shortcut method for setting the same property on the underlying pattern parser in use.

### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

`getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractHandlerMapping

    public AbstractHandlerMapping()

### Method Detail

#### setUseCaseSensitiveMatch

    public void setUseCaseSensitiveMatch(boolean caseSensitiveMatch)

Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:

- `getPathPatternParser()` -- the underlying pattern parser
- `PathPatternParser.setCaseSensitive(boolean)` -- the case sensitive slash option, including its default value.

Note: aside from

#### setUseTrailingSlashMatch

    public void setUseTrailingSlashMatch(boolean trailingSlashMatch)

Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:

- `getPathPatternParser()` -- the underlying pattern parser
- `PathPatternParser.setMatchOptionalTrailingSeparator(boolean)` -- the trailing slash option, including its default value.

#### getPathPatternParser

    public org.springframework.web.util.pattern.PathPatternParser getPathPatternParser()

Return the `PathPatternParser` instance that is used for `CORS configuration checks`. Sub-classes can also use this pattern parser for their own request mapping purposes.

#### setCorsConfigurations

    public void setCorsConfigurations(Map<String,org.springframework.web.cors.CorsConfiguration> corsConfigurations)

Set the "global" CORS configurations based on URL patterns. By default the first matching URL pattern is combined with handler-level CORS configuration if any.

See Also:
  `setCorsConfigurationSource(CorsConfigurationSource)`

#### setCorsConfigurationSource

    public void setCorsConfigurationSource(org.springframework.web.cors.reactive.CorsConfigurationSource corsConfigurationSource)

Set the "global" CORS configuration source. By default the first matching URL pattern is combined with the CORS configuration for the handler, if any.

Since:
  5.1
See Also:
  `setCorsConfigurations(Map)`

#### setCorsProcessor

    public void setCorsProcessor(org.springframework.web.cors.reactive.CorsProcessor corsProcessor)

Configure a custom `CorsProcessor` to use to apply the matched `CorsConfiguration` for a request.

By default an instance of `DefaultCorsProcessor` is used.

#### getCorsProcessor

    public org.springframework.web.cors.reactive.CorsProcessor getCorsProcessor()

Return the configured `CorsProcessor`.

#### setOrder

    public void setOrder(int order)

Specify the order value for this HandlerMapping bean.

The default value is `Ordered.LOWEST_PRECEDENCE`, meaning non-ordered.

See Also:
  `Ordered.getOrder()`

#### getOrder

    public int getOrder()

Specified by:
  `getOrder` in interface `org.springframework.core.Ordered`

#### setBeanName

    public void setBeanName(String name)

Specified by:
  `setBeanName` in interface `org.springframework.beans.factory.BeanNameAware`

#### formatMappingName

    protected String formatMappingName()

#### getHandler

    public reactor.core.publisher.Mono<Object> getHandler(org.springframework.web.server.ServerWebExchange exchange)

Description copied from interface: `HandlerMapping`
Return a handler for this request.

Specified by:
  `getHandler` in interface `HandlerMapping`
Parameters:
  `exchange` - current server exchange
Returns:
  a `Mono` that emits one value or none in case the request cannot be resolved to a handler

#### getHandlerInternal

    protected abstract reactor.core.publisher.Mono<?> getHandlerInternal(org.springframework.web.server.ServerWebExchange exchange)

Look up a handler for the given request, returning an empty `Mono` if no specific one is found. This method is called by `getHandler(org.springframework.web.server.ServerWebExchange)`.

On CORS pre-flight requests this method should return a match not for the pre-flight request but for the expected actual request based on the URL path, the HTTP methods from the "Access-Control-Request-Method" header, and the headers from the "Access-Control-Request-Headers" header.

Parameters:
  `exchange` - current exchange
Returns:
  `Mono` for the matching handler, if any

#### hasCorsConfigurationSource

    protected boolean hasCorsConfigurationSource(Object handler)

Return `true` if there is a `CorsConfigurationSource` for this handler.

Since:
  5.2

#### getCorsConfiguration

    @Nullable
    protected org.springframework.web.cors.CorsConfiguration getCorsConfiguration(Object handler,
                                                                                            org.springframework.web.server.ServerWebExchange exchange)

Retrieve the CORS configuration for the given handler.

Parameters:
  `handler` - the handler to check (never `null`)
  `exchange` - the current exchange
Returns:
  the CORS configuration for the handler, or `null` if none