Skip to content

Commit 5a4a66c

Browse files
gregturnmp911de
authored andcommitted
Backport replacement of RepositoryRestConfigurerAdapter in the ref docs to 3.4.x.
RepositoryRestConfigurerAdapter was superceded by RepositoryRestConfigurer and its default methods a long time ago. Update the ref docs to properly use the new interface. Fixes #1983.
1 parent b779187 commit 5a4a66c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/main/asciidoc/configuring-cors.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ The following example sets an allowed origin, adds the PUT and DELETE HTTP metho
6565
[source, java]
6666
----
6767
@Component
68-
public class SpringDataRestCustomization extends RepositoryRestConfigurerAdapter {
68+
public class SpringDataRestCustomization implements RepositoryRestConfigurer {
6969
7070
@Override
71-
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
71+
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
7272
73-
config.getCorsRegistry().addMapping("/person/**")
73+
cors.addMapping("/person/**")
7474
.allowedOrigins("http://domain2.example")
7575
.allowedMethods("PUT", "DELETE")
7676
.allowedHeaders("header1", "header2", "header3")

src/main/asciidoc/getting-started.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Spring Data REST configuration is defined in a class called `RepositoryRestMvcCo
8080

8181
IMPORTANT: This step is unnecessary if you use Spring Boot's auto-configuration. Spring Boot automatically enables Spring Data REST when you include *spring-boot-starter-data-rest* and, in your list of dependencies, your app is flagged with either `@SpringBootApplication` or `@EnableAutoConfiguration`.
8282

83-
To customize the configuration, register a `RepositoryRestConfigurer` (or extend `RepositoryRestConfigurerAdapter`) and implement or override the `configure…`-methods relevant to your use case.
83+
To customize the configuration, register a `RepositoryRestConfigurer` and implement or override the `configure…`-methods relevant to your use case.
8484

8585
Make sure you also configure Spring Data repositories for the store you use. For details on that, see the reference documentation for the https://projects.spring.io/spring-data/[corresponding Spring Data module].
8686

@@ -133,10 +133,10 @@ class CustomRestMvcConfiguration {
133133
@Bean
134134
public RepositoryRestConfigurer repositoryRestConfigurer() {
135135
136-
return new RepositoryRestConfigurerAdapter() {
136+
return new RepositoryRestConfigurer() {
137137
138138
@Override
139-
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
139+
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
140140
config.setBasePath("/api");
141141
}
142142
};
@@ -151,10 +151,10 @@ Alternatively, you can register a custom implementation of `RepositoryRestConfig
151151
[source,java]
152152
----
153153
@Component
154-
public class CustomizedRestMvcConfiguration extends RepositoryRestConfigurerAdapter {
154+
public class CustomizedRestMvcConfiguration extends RepositoryRestConfigurer {
155155
156156
@Override
157-
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
157+
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
158158
config.setBasePath("/api");
159159
}
160160
}

src/main/asciidoc/validation.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ In order to tell Spring Data REST you want a particular `Validator` assigned to
77

88
== Assigning Validators Manually
99

10-
If you would rather not use the bean name prefix approach, you need to register an instance of your validator with the bean whose job it is to invoke validators after the correct event. In your configuration that implements `RepositoryRestConfigurer` or subclasses Spring Data REST's `RepositoryRestConfigurerAdapter`, override the `configureValidatingRepositoryEventListener` method and call `addValidator` on the `ValidatingRepositoryEventListener`, passing the event on which you want this validator to be triggered and an instance of the validator. The following example shows how to do so:
10+
If you would rather not use the bean name prefix approach, you need to register an instance of your validator with the bean whose job it is to invoke validators after the correct event. In your configuration that implements `RepositoryRestConfigurer`, override the `configureValidatingRepositoryEventListener` method and call `addValidator` on the `ValidatingRepositoryEventListener`, passing the event on which you want this validator to be triggered and an instance of the validator. The following example shows how to do so:
1111

1212
====
1313
[source,java]
1414
----
1515
@Override
16-
protected void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener v) {
16+
void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener v) {
1717
v.addValidator("beforeSave", new BeforeSaveValidator());
1818
}
1919
----

0 commit comments

Comments
 (0)