Top Description Fields Constructors Methods
org.springframework.web.reactive.handler

public abstract Class AbstractHandlerMapping

extends ApplicationObjectSupport
implements HandlerMapping, Ordered, BeanNameAware
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.Aware, org.springframework.core.Ordered, org.springframework.web.reactive.HandlerMapping
Known Direct Subclasses
org.springframework.web.reactive.handler.AbstractUrlHandlerMapping, org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping, org.springframework.web.reactive.config.WebFluxConfigurationSupport.EmptyHandlerMapping, org.springframework.web.reactive.function.server.support.RouterFunctionMapping
Imports
java.util.Map, org.apache.commons.logging.Log, reactor.core.publisher.Mono, org.springframework.beans.factory.BeanNameAware, org.springframework.context.support.ApplicationObjectSupport, org.springframework.core.Ordered, org.springframework.core.log.LogDelegateFactory, org.springframework.http.server.reactive.ServerHttpRequest, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.cors.CorsConfiguration, org.springframework.web.cors.reactive.CorsConfigurationSource, .CorsProcessor, .CorsUtils, .DefaultCorsProcessor, .UrlBasedCorsConfigurationSource, org.springframework.web.reactive.HandlerMapping, org.springframework.web.server.ServerWebExchange, .WebHandler, org.springframework.web.util.pattern.PathPatternParser

Abstract base class for org.springframework.web.reactive.HandlerMapping implementations.
Authors
Rossen Stoyanchev, Juergen Hoeller, Brian Clozel
Since
5.0

Field Summary

Modifier and TypeField and Description
private String
private CorsConfigurationSource
private CorsProcessor
protected final Log
mappingsLogger

Dedicated "hidden" logger for request mappings.

private static final WebHandler
private int
private final PathPatternParser
Inherited from org.springframework.context.support.ApplicationObjectSupport:
logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
protected CorsConfiguration

Returns:

the CORS configuration for the handler, or null if none
getCorsConfiguration
(Object
the handler to check (never null)
handler
,
ServerWebExchange
the current exchange
exchange
)

Retrieve the CORS configuration for the given handler.

public CorsProcessor
getCorsProcessor()

Return the configured CorsProcessor.

public Mono<Object>
getHandler(ServerWebExchange
current server exchange
exchange
)

Implements org.springframework.web.reactive.HandlerMapping.getHandler.

Return a handler for this request.

protected abstract Mono<?>

Returns:

Mono for the matching handler, if any
getHandlerInternal
(ServerWebExchange
current exchange
exchange
)

Look up a handler for the given request, returning an empty Mono if no specific one is found.

public int
getOrder()

Implements org.springframework.core.Ordered.getOrder.

Get the order value of this object.

public 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.

public void
setBeanName(String
the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.
name
)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

Set the name of the bean in the bean factory that created this bean.

public void
setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations)

Set the "global" CORS configurations based on URL patterns.

public void
setCorsConfigurationSource(CorsConfigurationSource corsConfigurationSource)

Set the "global" CORS configuration source.

public void
setCorsProcessor(CorsProcessor corsProcessor)

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

public void
setOrder(int order)

Specify the order value for this HandlerMapping bean.

public void
setUseCaseSensitiveMatch(boolean caseSensitiveMatch)

Shortcut method for setting the same property on the underlying pattern parser in use.

public void
setUseTrailingSlashMatch(boolean trailingSlashMatch)

Shortcut method for setting the same property on the underlying pattern parser in use.

Inherited from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContextgetMessageSourceAccessorinitApplicationContextinitApplicationContextisContextRequiredobtainApplicationContextrequiredContextClasssetApplicationContext

Field Detail

beanNameback to summary
private String beanName
Annotations
@Nullable
corsConfigurationSourceback to summary
private CorsConfigurationSource corsConfigurationSource
Annotations
@Nullable
corsProcessorback to summary
private CorsProcessor corsProcessor
mappingsLoggerback to summary
protected final Log mappingsLogger

Dedicated "hidden" logger for request mappings.

NO_OP_HANDLERback to summary
private static final WebHandler NO_OP_HANDLER
orderback to summary
private int order
patternParserback to summary
private final PathPatternParser patternParser

Constructor Detail

AbstractHandlerMappingback to summary
public AbstractHandlerMapping()

Method Detail

formatMappingNameback to summary
protected String formatMappingName()
getCorsConfigurationback to summary
protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange)

Retrieve the CORS configuration for the given handler.

Parameters
handler:Object

the handler to check (never null)

exchange:ServerWebExchange

the current exchange

Returns:CorsConfiguration

the CORS configuration for the handler, or null if none

Annotations
@Nullable
getCorsProcessorback to summary
public CorsProcessor getCorsProcessor()

Return the configured CorsProcessor.

getHandlerback to summary
public Mono<Object> getHandler(ServerWebExchange exchange)

Implements org.springframework.web.reactive.HandlerMapping.getHandler.

Doc from org.springframework.web.reactive.HandlerMapping.getHandler.

Return a handler for this request.

Before returning a handler, an implementing method should check for CORS configuration associated with the handler, apply validation checks based on it, and update the response accordingly. For pre-flight requests, the same should be done based on the handler matching to the expected actual request.

Parameters
exchange:ServerWebExchange

current server exchange

Returns:Mono<Object>

a Mono that emits one value or none in case the request cannot be resolved to a handler

Annotations
@Override
getHandlerInternalback to summary
protected abstract Mono<?> getHandlerInternal(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.

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:ServerWebExchange

current exchange

Returns:Mono<?>

Mono for the matching handler, if any

getOrderback to summary
public int getOrder()

Implements org.springframework.core.Ordered.getOrder.

Doc from org.springframework.core.Ordered.getOrder.

Get the order value of this object.

Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet load-on-startup values).

Same order values will result in arbitrary sort positions for the affected objects.

Returns:int

the order value

Annotations
@Override
getPathPatternParserback to summary
public PathPatternParser getPathPatternParser()

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

hasCorsConfigurationSourceback to summary
protected boolean hasCorsConfigurationSource(Object handler)

Return true if there is a CorsConfigurationSource for this handler.

Since
5.2
setBeanNameback to summary
public void setBeanName(String name)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

Doc from org.springframework.beans.factory.BeanNameAware.setBeanName.

Set the name of the bean in the bean factory that created this bean.

Invoked after population of normal bean properties but before an init callback such as InitializingBean#afterPropertiesSet() or a custom init-method.

Parameters
name:String

the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.

Annotations
@Override
setCorsConfigurationsback to summary
public void setCorsConfigurations(Map<String, 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)
setCorsConfigurationSourceback to summary
public void setCorsConfigurationSource(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)
setCorsProcessorback to summary
public void setCorsProcessor(CorsProcessor corsProcessor)

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

By default an instance of DefaultCorsProcessor is used.

setOrderback to summary
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
org.springframework.core.Ordered#getOrder()
setUseCaseSensitiveMatchback to summary
public void setUseCaseSensitiveMatch(boolean caseSensitiveMatch)

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

Note

aside from

setUseTrailingSlashMatchback to summary
public void setUseTrailingSlashMatch(boolean trailingSlashMatch)

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

The default was changed in 6.0 from true to false in order to support the deprecation of the property.

Annotations
@Deprecated
since:6.0