Skip to content

Commit d7f36b1

Browse files
committed
DATAREST-1540 - Improvements in HandlerMapping implementation for Spring 5.3.
We now use Spring's path prefix capabilities to apply Spring Data REST's base path to its mappings. This was previously implemented by tweaking the matching conditions. We now also pick up Spring 5.3's PathPatternParser and apply that to the custom HandlerMapping implementations we register. Moved DelegatingHandlerMapping into the configuration package to be able to keep it around in package scope. Deprecated RepositoryRestConfiguration.getBaseUri() as we have only supported paths for quite a while now. Moved all client code to ….getBasePath() instead.
1 parent 8992e21 commit d7f36b1

File tree

11 files changed

+111
-500
lines changed

11 files changed

+111
-500
lines changed

spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
@SuppressWarnings("deprecation")
5252
public class RepositoryRestConfiguration {
5353

54-
private static final URI NO_URI = URI.create("");
54+
static final URI NO_URI = URI.create("");
5555

5656
private URI baseUri = NO_URI;
5757
private URI basePath = NO_URI;
@@ -109,7 +109,9 @@ public RepositoryRestConfiguration(ProjectionDefinitionConfiguration projectionC
109109
* The base URI against which the exporter should calculate its links.
110110
*
111111
* @return The base URI.
112+
* @deprecated use {@link #getBasePath()} instead.
112113
*/
114+
@Deprecated
113115
public URI getBaseUri() {
114116
return basePath != NO_URI ? basePath : baseUri;
115117
}

spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMappingIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import org.springframework.beans.factory.annotation.Autowired;
2222
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
2323
import org.springframework.data.rest.tests.mongodb.MongoDbRepositoryConfig;
24-
import org.springframework.data.rest.webmvc.support.DelegatingHandlerMapping;
2524
import org.springframework.mock.web.MockHttpServletRequest;
2625
import org.springframework.test.context.ContextConfiguration;
2726
import org.springframework.web.method.HandlerMethod;
2827
import org.springframework.web.servlet.HandlerExecutionChain;
28+
import org.springframework.web.servlet.HandlerMapping;
2929

3030
/**
3131
* Integration tests for {@link BasePathAwareHandlerMapping}.
@@ -36,7 +36,7 @@
3636
@ContextConfiguration(classes = MongoDbRepositoryConfig.class)
3737
public class RepositoryRestHandlerMappingIntegrationTests extends AbstractControllerIntegrationTests {
3838

39-
@Autowired DelegatingHandlerMapping mapping;
39+
@Autowired HandlerMapping mapping;
4040

4141
@Test // DATAREST-617
4242
public void usesMethodsWithoutProducesClauseForGeneralJsonRequests() throws Exception {

0 commit comments

Comments
 (0)