HandlerMethod containing the conditions
needed to match the handler method to an incoming request.
HandlerMapping implementations that define
a mapping between a request and a HandlerMethod.
For each registered handler method, a unique mapping is maintained with
subclasses defining the details of the mapping type <T>.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv class | AbstractHandlerMethodMapping.
A registry that maintains all mappings to handler methods, exposing methods to perform lookups and providing concurrent access. |
| private class | AbstractHandlerMethodMapping.
A thin wrapper around a matched HandlerMethod and its mapping, for the purpose of comparing the best match with a comparator in the context of the current request. |
| private class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final CorsConfiguration | |
| private final AbstractHandlerMethodMapping | |
| private static final HandlerMethod | PREFLIGHT_AMBIGUOUS_MATCH
HandlerMethod to return on a pre-flight request match when the request mappings are more nuanced than the access control headers. |
| private static final String | SCOPED_TARGET_NAME_PREFIX
Bean name prefix for target beans behind scoped proxies. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | addMatchingMappings(Collection<T> mappings, List<AbstractHandlerMethodMapping<T>.
|
| public void | afterPropertiesSet()
Implements org. Detects handler methods at initialization. |
| protected HandlerMethod | Returns: the created HandlerMethodeither a bean name or an actual handler instance handler, Method the target method method)Create the HandlerMethod instance. |
| protected void | detectHandlerMethods(final Object
the bean name of a handler or a handler instance handler)Look for handler methods in a handler. |
| private String | |
| protected CorsConfiguration | getCorsConfiguration(Object
the handler to check (never handler, ServerWebExchange null)the current exchange exchange)Overrides org. Retrieve the CORS configuration for the given handler. |
| protected Set | |
| public Mono | getHandlerInternal(ServerWebExchange
the current exchange exchange)Implements abstract org. Look up a handler method for the given request. |
| public Map | |
| protected abstract Comparator | Returns: the comparator (nevernull)the current exchange exchange)Return a comparator for sorting matching mappings. |
| protected abstract T | Returns: the mapping, ornull if the method is not mappedthe method to provide a mapping for method, Class<?> the handler type, possibly a subtype of the method's
declaring class handlerType)Provide the mapping for a handler method. |
| pack-priv AbstractHandlerMethodMapping | |
| protected abstract T | Returns: the match, ornull if the mapping doesn't matchthe mapping to get a match for mapping, ServerWebExchange the current exchange exchange)Check if a mapping matches the current request and return a (potentially new) mapping with conditions relevant to the current request. |
| protected void | handleMatch(T
the matching mapping mapping, HandlerMethod the matching method handlerMethod, ServerWebExchange the current exchange exchange)Invoked when a matching mapping is found. |
| protected HandlerMethod | Returns: an alternative HandlerMethod ornullall registered mappings mappings, ServerWebExchange the current exchange exchange)Invoked when no matching mapping is not found. |
| protected void | handlerMethodsInitialized(Map<T, HandlerMethod>
a read-only map with handler methods and mappings. handlerMethods)Invoked after all handler methods have been detected. |
| protected boolean | hasCorsConfigurationSource(Object handler)
Overrides org. Return |
| protected CorsConfiguration | initCorsConfiguration(Object handler, Method method, T mapping)
Extract and return the CORS configuration for the mapping. |
| protected void | |
| protected abstract boolean | |
| protected HandlerMethod | Returns: the best-matching handler method, ornull if no matchthe current exchange exchange)Look up the best-matching handler method for the current request. |
| protected void | registerHandlerMethod(Object
the bean name of the handler or the handler instance handler, Method the method to register method, T the mapping conditions associated with the handler method mapping)Register a handler method and its unique mapping. |
| public void | registerMapping(T
the mapping for the handler method mapping, Object the handler handler, Method the method method)Register the given mapping. |
| public void |
| ALLOW_CORS_CONFIG | back to summary |
|---|---|
| private static final CorsConfiguration ALLOW_CORS_CONFIG | |
| mappingRegistry | back to summary |
|---|---|
| private final AbstractHandlerMethodMapping<T>. | |
| PREFLIGHT_AMBIGUOUS_MATCH | back to summary |
|---|---|
| private static final HandlerMethod PREFLIGHT_AMBIGUOUS_MATCH HandlerMethod to return on a pre-flight request match when the request mappings are more nuanced than the access control headers. | |
| SCOPED_TARGET_NAME_PREFIX | back to summary |
|---|---|
| private static final String SCOPED_TARGET_NAME_PREFIX Bean name prefix for target beans behind scoped proxies. Used to exclude those targets from handler method detection, in favor of the corresponding proxies. We're not checking the autowire-candidate status here, which is how the
proxy target filtering problem is being handled at the autowiring level,
since autowire-candidate may have been turned to Originally defined in | |
| AbstractHandlerMethodMapping | back to summary |
|---|---|
| public AbstractHandlerMethodMapping() | |
| addMatchingMappings | back to summary |
|---|---|
| private void addMatchingMappings(Collection<T> mappings, List<AbstractHandlerMethodMapping<T>. | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() Implements org. Detects handler methods at initialization.
| |
| createHandlerMethod | back to summary |
|---|---|
| protected HandlerMethod createHandlerMethod(Object handler, Method method) Create the HandlerMethod instance.
| |
| detectHandlerMethods | back to summary |
|---|---|
| protected void detectHandlerMethods(final Object handler) Look for handler methods in a handler.
| |
| formatMappings | back to summary |
|---|---|
| private String formatMappings(Class<?> userType, Map<Method, T> methods) | |
| getCorsConfiguration | back to summary |
|---|---|
| protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange) Overrides org. Doc from org. Retrieve the CORS configuration for the given handler.
| |
| getDirectPaths | back to summary |
|---|---|
| protected Set Return the request mapping paths that are not patterns.
| |
| getHandlerInternal | back to summary |
|---|---|
| public Mono Implements abstract org. Look up a handler method for the given request.
| |
| getHandlerMethods | back to summary |
|---|---|
| public Map Return a (read-only) map with all mappings and HandlerMethod's. | |
| getMappingComparator | back to summary |
|---|---|
| protected abstract Comparator Return a comparator for sorting matching mappings. The returned comparator should sort 'better' matches higher.
| |
| getMappingForMethod | back to summary |
|---|---|
| protected abstract T getMappingForMethod(Method method, Class<?> handlerType) Provide the mapping for a handler method. A method for which no mapping can be provided is not a handler method. | |
| getMappingRegistry | back to summary |
|---|---|
| pack-priv AbstractHandlerMethodMapping Return the internal mapping registry. Provided for testing purposes. | |
| getMatchingMapping | back to summary |
|---|---|
| protected abstract T getMatchingMapping(T mapping, ServerWebExchange exchange) Check if a mapping matches the current request and return a (potentially new) mapping with conditions relevant to the current request.
| |
| handleMatch | back to summary |
|---|---|
| protected void handleMatch(T mapping, HandlerMethod handlerMethod, ServerWebExchange exchange) Invoked when a matching mapping is found.
| |
| handleNoMatch | back to summary |
|---|---|
| protected HandlerMethod handleNoMatch(Set<T> mappings, ServerWebExchange exchange) throws Exception Invoked when no matching mapping is not found.
| |
| handlerMethodsInitialized | back to summary |
|---|---|
| protected void handlerMethodsInitialized(Map<T, HandlerMethod> handlerMethods) Invoked after all handler methods have been detected.
| |
| hasCorsConfigurationSource | back to summary |
|---|---|
| protected boolean hasCorsConfigurationSource(Object handler) Overrides org. Doc from org. Return
| |
| initCorsConfiguration | back to summary |
|---|---|
| protected CorsConfiguration initCorsConfiguration(Object handler, Method method, T mapping) Extract and return the CORS configuration for the mapping.
| |
| initHandlerMethods | back to summary |
|---|---|
| protected void initHandlerMethods() Scan beans in the ApplicationContext, detect and register handler methods. | |
| isHandler | back to summary |
|---|---|
| protected abstract boolean isHandler(Class<?> beanType) Whether the given type is a handler with handler methods.
| |
| lookupHandlerMethod | back to summary |
|---|---|
| protected HandlerMethod lookupHandlerMethod(ServerWebExchange exchange) throws Exception Look up the best-matching handler method for the current request. If multiple matches are found, the best match is selected.
| |
| registerHandlerMethod | back to summary |
|---|---|
| protected void registerHandlerMethod(Object handler, Method method, T mapping) Register a handler method and its unique mapping. Invoked at startup for each detected handler method.
| |
| registerMapping | back to summary |
|---|---|
| public void registerMapping(T mapping, Object handler, Method method) Register the given mapping. This method may be invoked at runtime after initialization has completed. | |
| unregisterMapping | back to summary |
|---|---|
| public void unregisterMapping(T mapping) Un-register the given mapping. This method may be invoked at runtime after initialization has completed.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final Set | |
| private final HandlerMethod | |
| private final T |
| Access | Constructor and Description |
|---|---|
| public | MappingRegistration(T mapping, HandlerMethod handlerMethod, Set<String> directPaths, boolean corsConfig)
|
| Modifier and Type | Method and Description |
|---|---|
| public Set | |
| public HandlerMethod | |
| public T | |
| public boolean |
| corsConfig | back to summary |
|---|---|
| private final boolean corsConfig | |
| directPaths | back to summary |
|---|---|
| private final Set<String> directPaths | |
| handlerMethod | back to summary |
|---|---|
| private final HandlerMethod handlerMethod | |
| mapping | back to summary |
|---|---|
| private final T mapping | |
| MappingRegistration | back to summary |
|---|---|
| public MappingRegistration(T mapping, HandlerMethod handlerMethod, Set<String> directPaths, boolean corsConfig) | |
| getDirectPaths | back to summary |
|---|---|
| public Set | |
| getHandlerMethod | back to summary |
|---|---|
| public HandlerMethod getHandlerMethod() | |
| getMapping | back to summary |
|---|---|
| public T getMapping() | |
| hasCorsConfig | back to summary |
|---|---|
| public boolean hasCorsConfig() | |
Package-private for testing purposes.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final MultiValueMap | |
| private final ReentrantReadWriteLock | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public CorsConfiguration | |
| public List | |
| public Map | |
| public void | |
| public void | |
| public void | |
| private void |
| corsLookup | back to summary |
|---|---|
| private final Map<HandlerMethod, CorsConfiguration> corsLookup | |
| pathLookup | back to summary |
|---|---|
| private final MultiValueMap<String, T> pathLookup | |
| readWriteLock | back to summary |
|---|---|
| private final ReentrantReadWriteLock readWriteLock | |
| registry | back to summary |
|---|---|
| private final Map<T, AbstractHandlerMethodMapping. | |
| MappingRegistry | back to summary |
|---|---|
| pack-priv MappingRegistry() | |
| acquireReadLock | back to summary |
|---|---|
| public void acquireReadLock() Acquire the read lock when using getMappings and getMappingsByUrl. | |
| getCorsConfiguration | back to summary |
|---|---|
| public CorsConfiguration getCorsConfiguration(HandlerMethod handlerMethod) Return CORS configuration. Thread-safe for concurrent use.
| |
| getMappingsByDirectPath | back to summary |
|---|---|
| public List Return matches for the given URL path. Not thread-safe.
| |
| getRegistrations | back to summary |
|---|---|
| public Map Return all registrations.
| |
| register | back to summary |
|---|---|
| public void register(T mapping, Object handler, Method method) | |
| releaseReadLock | back to summary |
|---|---|
| public void releaseReadLock() Release the read lock after using getMappings and getMappingsByUrl. | |
| unregister | back to summary |
|---|---|
| public void unregister(T mapping) | |
| validateMethodMapping | back to summary |
|---|---|
| private void validateMethodMapping(HandlerMethod handlerMethod, T mapping) | |
| Modifier and Type | Field and Description |
|---|---|
| private final T | |
| private final AbstractHandlerMethodMapping. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public HandlerMethod | |
| public boolean | |
| public String |
| mapping | back to summary |
|---|---|
| private final T mapping | |
| registration | back to summary |
|---|---|
| private final AbstractHandlerMethodMapping. | |
| Match | back to summary |
|---|---|
| public Match(T mapping, AbstractHandlerMethodMapping. | |
| getHandlerMethod | back to summary |
|---|---|
| public HandlerMethod getHandlerMethod() | |
| hasCorsConfig | back to summary |
|---|---|
| public boolean hasCorsConfig() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(AbstractHandlerMethodMapping<T>.
the first object to be compared. match1,the second object to be compared. match2Implements java. Compares its two arguments for order. |
| comparator | back to summary |
|---|---|
| private final Comparator<T> comparator | |
| MatchComparator | back to summary |
|---|---|
| public MatchComparator(Comparator<T> comparator) | |
| compare | back to summary |
|---|---|
| public int compare(AbstractHandlerMethodMapping<T>. Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| PreFlightAmbiguousMatchHandler | back to summary |
|---|---|
| private PreFlightAmbiguousMatchHandler() | |
| handle | back to summary |
|---|---|
public void handle()
| |