Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.result.method.annotation

public Class RequestMappingHandlerMapping

extends RequestMappingInfoHandlerMapping
implements EmbeddedValueResolverAware
Class Inheritance
All Implemented Interfaces
org.springframework.context.EmbeddedValueResolverAware, org.springframework.beans.factory.Aware
Imports
java.lang.annotation.Annotation, java.lang.reflect.AnnotatedElement, .Method, .Parameter, java.util.Collections, .LinkedHashMap, .List, .Map, java.util.function.Predicate, java.util.stream.Stream, org.springframework.context.EmbeddedValueResolverAware, org.springframework.core.annotation.AnnotatedElementUtils, .MergedAnnotation, .MergedAnnotationPredicates, .MergedAnnotations, .MergedAnnotations.SearchStrategy, .RepeatableContainers, org.springframework.lang.Nullable, org.springframework.stereotype.Controller, org.springframework.util.Assert, .CollectionUtils, .StringUtils, .StringValueResolver, org.springframework.web.bind.annotation.CrossOrigin, .RequestBody, .RequestMapping, .RequestMethod, org.springframework.web.cors.CorsConfiguration, org.springframework.web.method.HandlerMethod, org.springframework.web.reactive.accept.RequestedContentTypeResolver, .RequestedContentTypeResolverBuilder, org.springframework.web.reactive.result.condition.ConsumesRequestCondition, .RequestCondition, org.springframework.web.reactive.result.method.RequestMappingInfo, .RequestMappingInfoHandlerMapping, org.springframework.web.service.annotation.HttpExchange

An extension of RequestMappingInfoHandlerMapping that creates RequestMappingInfo instances from type-level and method-level @RequestMapping and @HttpExchange annotations.
Authors
Rossen Stoyanchev, Sam Brannen, Olga Maciaszek-Sharma
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private RequestMappingInfo.BuilderConfiguration
private RequestedContentTypeResolver
private StringValueResolver
private static final RequestMethod[]
private static final String[]
private final Map<String, Predicate<Class<?>>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
private RequestMappingInfo
protected RequestMappingInfo
createRequestMappingInfo(RequestMapping requestMapping, RequestCondition<?> customCondition)

Create a RequestMappingInfo from the supplied @RequestMapping annotation, meta-annotation, or synthesized result of merging annotation attributes within an annotation hierarchy.

protected RequestMappingInfo
createRequestMappingInfo(HttpExchange httpExchange, RequestCondition<?> customCondition)

Create a RequestMappingInfo from the supplied @HttpExchange annotation, meta-annotation, or synthesized result of merging annotation attributes within an annotation hierarchy.

private static List<RequestMappingHandlerMapping.AnnotationDescriptor>
public RequestedContentTypeResolver
protected RequestCondition<?>

Returns:

the condition, or null
getCustomMethodCondition
(Method
the handler method for which to create the condition
method
)

Protected method to provide a custom method-level request condition.

protected RequestCondition<?>

Returns:

the condition, or null
getCustomTypeCondition
(Class<?>
the handler type for which to create the condition
handlerType
)

Protected method to provide a custom type-level request condition.

protected RequestMappingInfo

Returns:

the created RequestMappingInfo, or null if the method does not have a @RequestMapping or @HttpExchange annotation
getMappingForMethod
(Method
the method to provide a mapping for
method
,
Class<?>
the handler type, possibly a subtype of the method's declaring class
handlerType
)

Implements abstract org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.getMappingForMethod.

Uses type-level and method-level @RequestMapping and @HttpExchange annotations to create the RequestMappingInfo.

public Map<String, Predicate<Class<?>>>
getPathPrefixes()

The configured path prefixes as a read-only, possibly empty map.

protected CorsConfiguration
initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo)

Overrides org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.initCorsConfiguration.

Extract and return the CORS configuration for the mapping.

protected boolean
isHandler(Class<?>
the type of the bean being checked
beanType
)

Implements abstract org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.isHandler.

Whether the given type is a handler with handler methods.

protected void
registerHandlerMethod(Object
the bean name of the handler or the handler instance
handler
,
Method
the method to register
method
,
RequestMappingInfo
the mapping conditions associated with the handler method
mapping
)

Overrides org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.registerHandlerMethod.

Register a handler method and its unique mapping.

public void
registerMapping(RequestMappingInfo
the mapping for the handler method
mapping
,
Object
the handler
handler
,
Method
the method
method
)

Overrides org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.registerMapping.

Register the given mapping.

private String
protected String[]

Returns:

a new array with updated patterns
resolveEmbeddedValuesInPatterns
(String[] patterns)

Resolve placeholder values in the given array of patterns.

public void
setContentTypeResolver(RequestedContentTypeResolver contentTypeResolver)

Set the RequestedContentTypeResolver to use to determine requested media types.

public void
setEmbeddedValueResolver(StringValueResolver resolver)

Implements org.springframework.context.EmbeddedValueResolverAware.setEmbeddedValueResolver.

Set the StringValueResolver to use for resolving embedded definition values.

public void
setPathPrefixes(Map<String, Predicate<Class<?>>>
a map with path prefixes as key
prefixes
)

Configure path prefixes to apply to controller methods.

private static RequestMethod[]
private static String[]
private void
private void
Inherited from org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping:
getDirectPathsgetHandlerInternalgetMappingComparatorgetMatchingMappinghandleMatchhandleNoMatch

Field Detail

configback to summary
private RequestMappingInfo.BuilderConfiguration config
contentTypeResolverback to summary
private RequestedContentTypeResolver contentTypeResolver
embeddedValueResolverback to summary
private StringValueResolver embeddedValueResolver
Annotations
@Nullable
EMPTY_REQUEST_METHOD_ARRAYback to summary
private static final RequestMethod[] EMPTY_REQUEST_METHOD_ARRAY
EMPTY_STRING_ARRAYback to summary
private static final String[] EMPTY_STRING_ARRAY
pathPrefixesback to summary
private final Map<String, Predicate<Class<?>>> pathPrefixes

Constructor Detail

RequestMappingHandlerMappingback to summary
public RequestMappingHandlerMapping()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet()

Overrides org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.afterPropertiesSet.

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.afterPropertiesSet.

Detects handler methods at initialization.

Annotations
@Override
createRequestMappingInfoback to summary
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element)
Annotations
@Nullable
createRequestMappingInfoback to summary
protected RequestMappingInfo createRequestMappingInfo(RequestMapping requestMapping, RequestCondition<?> customCondition)

Create a RequestMappingInfo from the supplied @RequestMapping annotation, meta-annotation, or synthesized result of merging annotation attributes within an annotation hierarchy.

createRequestMappingInfoback to summary
protected RequestMappingInfo createRequestMappingInfo(HttpExchange httpExchange, RequestCondition<?> customCondition)

Create a RequestMappingInfo from the supplied @HttpExchange annotation, meta-annotation, or synthesized result of merging annotation attributes within an annotation hierarchy.

Since
6.1
getAnnotationDescriptorsback to summary
private static List<RequestMappingHandlerMapping.AnnotationDescriptor> getAnnotationDescriptors(AnnotatedElement element)
getContentTypeResolverback to summary
public RequestedContentTypeResolver getContentTypeResolver()

Return the configured RequestedContentTypeResolver.

getCustomMethodConditionback to summary
protected RequestCondition<?> getCustomMethodCondition(Method method)

Protected method to provide a custom method-level request condition.

The custom RequestCondition can be of any type so long as the same condition type is returned from all calls to this method in order to ensure custom request conditions can be combined and compared.

Consider extending AbstractRequestCondition for custom condition types and using CompositeRequestCondition to provide multiple custom conditions.

Parameters
method:Method

the handler method for which to create the condition

Returns:RequestCondition<?>

the condition, or null

Annotations
@SuppressWarnings:UnusedParameters
@Nullable
getCustomTypeConditionback to summary
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType)

Protected method to provide a custom type-level request condition.

The custom RequestCondition can be of any type so long as the same condition type is returned from all calls to this method in order to ensure custom request conditions can be combined and compared.

Consider extending AbstractRequestCondition for custom condition types and using CompositeRequestCondition to provide multiple custom conditions.

Parameters
handlerType:Class<?>

the handler type for which to create the condition

Returns:RequestCondition<?>

the condition, or null

Annotations
@SuppressWarnings:UnusedParameters
@Nullable
getMappingForMethodback to summary
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType)

Implements abstract org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.getMappingForMethod.

Uses type-level and method-level @RequestMapping and @HttpExchange annotations to create the RequestMappingInfo.

Parameters
method:Method

Doc from org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.getMappingForMethod.

the method to provide a mapping for

handlerType:Class<?>

Doc from org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.getMappingForMethod.

the handler type, possibly a subtype of the method's declaring class

Returns:RequestMappingInfo

the created RequestMappingInfo, or null if the method does not have a @RequestMapping or @HttpExchange annotation

Annotations
@Override
@Nullable
See Also
getCustomMethodCondition(Method), getCustomTypeCondition(Class)
getPathPrefixesback to summary
public Map<String, Predicate<Class<?>>> getPathPrefixes()

The configured path prefixes as a read-only, possibly empty map.

Since
5.1
initCorsConfigurationback to summary
protected CorsConfiguration initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo)

Overrides org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.initCorsConfiguration.

Doc from org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.initCorsConfiguration.

Extract and return the CORS configuration for the mapping.

Annotations
@Override
isHandlerback to summary
protected boolean isHandler(Class<?> beanType)

Implements abstract org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.isHandler.

Doc from org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.isHandler.

Whether the given type is a handler with handler methods. Expects a handler to have a type-level @Controller annotation.

Parameters
beanType:Class<?>

the type of the bean being checked

Returns:boolean

"true" if this a handler type, "false" otherwise.

Annotations
@Override
registerHandlerMethodback to summary
protected void registerHandlerMethod(Object handler, Method method, RequestMappingInfo mapping)

Overrides org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.registerHandlerMethod.

Doc from org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.registerHandlerMethod.

Register a handler method and its unique mapping. Invoked at startup for each detected handler method.

Parameters
handler:Object

the bean name of the handler or the handler instance

method:Method

the method to register

mapping:RequestMappingInfo

the mapping conditions associated with the handler method

Annotations
@Override
registerMappingback to summary
public void registerMapping(RequestMappingInfo mapping, Object handler, Method method)

Overrides org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.registerMapping.

Doc from org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping.registerMapping.

Register the given mapping.

This method may be invoked at runtime after initialization has completed.

Parameters
mapping:RequestMappingInfo

the mapping for the handler method

handler:Object

the handler

method:Method

the method

Annotations
@Override
resolveCorsAnnotationValueback to summary
private String resolveCorsAnnotationValue(String value)
resolveEmbeddedValuesInPatternsback to summary
protected String[] resolveEmbeddedValuesInPatterns(String[] patterns)

Resolve placeholder values in the given array of patterns.

Returns:String[]

a new array with updated patterns

setContentTypeResolverback to summary
public void setContentTypeResolver(RequestedContentTypeResolver contentTypeResolver)

Set the RequestedContentTypeResolver to use to determine requested media types. If not set, the default constructor is used.

setEmbeddedValueResolverback to summary
public void setEmbeddedValueResolver(StringValueResolver resolver)

Implements org.springframework.context.EmbeddedValueResolverAware.setEmbeddedValueResolver.

Doc from org.springframework.context.EmbeddedValueResolverAware.setEmbeddedValueResolver.

Set the StringValueResolver to use for resolving embedded definition values.

Annotations
@Override
setPathPrefixesback to summary
public void setPathPrefixes(Map<String, Predicate<Class<?>>> prefixes)

Configure path prefixes to apply to controller methods.

Prefixes are used to enrich the mappings of every @RequestMapping method and @HttpExchange method whose controller type is matched by a corresponding Predicate in the map. The prefix for the first matching predicate is used, assuming the input map has predictable order.

Consider using HandlerTypePredicate to group controllers.

Parameters
prefixes:Map<String, Predicate<Class<?>>>

a map with path prefixes as key

Since
5.1
See Also
org.springframework.web.method.HandlerTypePredicate
toMethodArrayback to summary
private static RequestMethod[] toMethodArray(String method)
toStringArrayback to summary
private static String[] toStringArray(String value)
updateConsumesConditionback to summary
private void updateConsumesCondition(RequestMappingInfo info, Method method)
updateCorsConfigback to summary
private void updateCorsConfig(CorsConfiguration config, CrossOrigin annotation)
org.springframework.web.reactive.result.method.annotation back to summary

private Class RequestMappingHandlerMapping.AnnotationDescriptor

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping.AnnotationDescriptor

Field Summary

Modifier and TypeField and Description
private final Annotation
private final MergedAnnotation<?>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

annotationback to summary
private final Annotation annotation
rootback to summary
private final MergedAnnotation<?> root

Constructor Detail

AnnotationDescriptorback to summary
pack-priv AnnotationDescriptor(MergedAnnotation<Annotation> mergedAnnotation)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override