Let DelegatingHandlerMapping implement HandlerMapping directly.
We actually do not want to inherit all the functionality implemented in AbstractHandlerMapping. The sole reason we did so before was to override the method to propagate the PathPatternResolver to the downstream HandlerMappings. We now just declare the method on DHM directly. Fixes GH-1955.
This commit is contained in:
@@ -41,8 +41,8 @@ import org.springframework.web.util.pattern.PathPatternParser;
|
||||
* @author Oliver Gierke
|
||||
* @soundtrack Benny Greb - Stabila (Moving Parts)
|
||||
*/
|
||||
class DelegatingHandlerMapping extends AbstractHandlerMapping
|
||||
implements org.springframework.data.rest.webmvc.support.DelegatingHandlerMapping {
|
||||
class DelegatingHandlerMapping
|
||||
implements org.springframework.data.rest.webmvc.support.DelegatingHandlerMapping, Ordered {
|
||||
|
||||
private final List<HandlerMapping> delegates;
|
||||
|
||||
@@ -58,15 +58,7 @@ class DelegatingHandlerMapping extends AbstractHandlerMapping
|
||||
this.delegates = delegates;
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public List<HandlerMapping> getDelegates() {
|
||||
return this.delegates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPatternParser(PathPatternParser parser) {
|
||||
|
||||
super.setPatternParser(parser);
|
||||
void setPatternParser(PathPatternParser parser) {
|
||||
|
||||
delegates.stream() //
|
||||
.filter(AbstractHandlerMapping.class::isInstance) //
|
||||
@@ -74,6 +66,11 @@ class DelegatingHandlerMapping extends AbstractHandlerMapping
|
||||
.forEach(it -> it.setPatternParser(parser));
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public List<HandlerMapping> getDelegates() {
|
||||
return this.delegates;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
@@ -94,10 +91,10 @@ class DelegatingHandlerMapping extends AbstractHandlerMapping
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.web.servlet.handler.AbstractHandlerMapping#getHandlerInternal(javax.servlet.http.HttpServletRequest)
|
||||
* @see org.springframework.web.servlet.HandlerMapping#getHandler(javax.servlet.http.HttpServletRequest)
|
||||
*/
|
||||
@Override
|
||||
protected Object getHandlerInternal(HttpServletRequest request) throws Exception {
|
||||
public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
|
||||
return HandlerSelectionResult.from(request, delegates).resultOrException();
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
|
||||
private Lazy<BaseUri> baseUri;
|
||||
private Lazy<RepositoryResourceMappings> resourceMappings;
|
||||
private Lazy<Repositories> repositories;
|
||||
private Lazy<AbstractHandlerMapping> restHandlerMapping;
|
||||
private Lazy<DelegatingHandlerMapping> restHandlerMapping;
|
||||
private Lazy<ResourceMetadataHandlerMethodArgumentResolver> resourceMetadataHandlerMethodArgumentResolver;
|
||||
private Lazy<ExcerptProjector> excerptProjector;
|
||||
private Lazy<PersistentEntities> persistentEntities;
|
||||
@@ -240,7 +240,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
|
||||
this.baseUri = Lazy.of(() -> context.getBean(BaseUri.class));
|
||||
this.resourceMappings = Lazy.of(() -> context.getBean(RepositoryResourceMappings.class));
|
||||
this.repositories = Lazy.of(() -> context.getBean(Repositories.class));
|
||||
this.restHandlerMapping = Lazy.of(() -> context.getBean("restHandlerMapping", AbstractHandlerMapping.class));
|
||||
this.restHandlerMapping = Lazy.of(() -> context.getBean("restHandlerMapping", DelegatingHandlerMapping.class));
|
||||
this.resourceMetadataHandlerMethodArgumentResolver = Lazy
|
||||
.of(() -> context.getBean(ResourceMetadataHandlerMethodArgumentResolver.class));
|
||||
this.excerptProjector = Lazy.of(() -> context.getBean(ExcerptProjector.class));
|
||||
@@ -637,7 +637,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public AbstractHandlerMapping restHandlerMapping(Repositories repositories,
|
||||
public DelegatingHandlerMapping restHandlerMapping(Repositories repositories,
|
||||
RepositoryResourceMappings resourceMappings, Optional<JpaHelper> jpaHelper,
|
||||
RepositoryRestConfiguration repositoryRestConfiguration, CorsConfigurationAware corsRestConfiguration) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user