Skip to content

Commit 59b52c6

Browse files
committed
Consistent anchor names for headings in documentation.
1 parent 0b28309 commit 59b52c6

15 files changed

+61
-22
lines changed

src/main/asciidoc/adding-sdr-to-spring-mvc-app.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ The following example shows the corresponding XML configuration:
3333

3434
When your ApplicationContext comes across this bean definition, it bootstraps the necessary Spring MVC resources to fully configure the controller for exporting the repositories it finds in that `ApplicationContext` and any parent contexts.
3535

36+
[[customizing-sdr.adding-sdr-to-spring-mvc-app.required-config]]
3637
== More on Required Configuration
3738

3839
Spring Data REST depends on a couple Spring MVC resources that must be configured correctly for it to work inside an existing Spring MVC application. We tried to isolate those resources from whatever similar resources already exist within your application, but it may be that you want to customize some of the behavior of Spring Data REST by modifying these MVC components.
3940

4041
You should pay special attention to configuring `RepositoryRestHandlerMapping`, covered in the next section.
4142

43+
[[customizing-sdr.adding-sdr-to-spring-mvc-app.required-config.mapping]]
4244
=== `RepositoryRestHandlerMapping`
4345

4446
We register a custom `HandlerMapping` instance that responds only to the `RepositoryRestController` and only if a path is meant to be handled by Spring Data REST. In order to keep paths that are meant to be handled by your application separate from those handled by Spring Data REST, this custom `HandlerMapping` class inspects the URL path and checks to see if a repository has been exported under that name. If it has, the custom `HandlerMapping` class lets the request be handled by Spring Data REST. If there is no Repository exported under that name, it returns `null`, which means "`let other `HandlerMapping` instances try to service this request`".

src/main/asciidoc/configuring-cors.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ For security reasons, browsers prohibit AJAX calls to resources residing outside
55

66
Spring Data REST, as of 2.6, supports https://en.wikipedia.org/wiki/Cross-origin_resource_sharing[Cross-Origin Resource Sharing] (CORS) through https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/web.html#mvc-cors[Spring's CORS] support.
77

8-
8+
[[customizing-sdr.configuring-cors.config]]
99
== Repository Interface CORS Configuration
1010

1111
You can add a `@CrossOrigin` annotation to your repository interfaces to enable CORS for the whole repository. By default, `@CrossOrigin` allows all origins and HTTP methods. The following example shows a cross-origin repository interface definition:
@@ -32,6 +32,7 @@ interface PersonRepository extends CrudRepository<Person, Long> {}
3232

3333
The preceding example enables CORS support for the whole `PersonRepository` by providing one origin, restricted to the `GET`, `POST`, and `DELETE` methods and with a max age of 3600 seconds.
3434

35+
[[customizing-sdr.configuring-cors.controller-config]]
3536
== Repository REST Controller Method CORS Configuration
3637

3738
Spring Data REST fully supports https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/web.html#controller-method-cors-configuration[Spring Web MVC's controller method configuration] on custom REST controllers that share repository base paths, as the following example shows:
@@ -53,6 +54,7 @@ public class PersonController {
5354

5455
NOTE: Controllers annotated with `@RepositoryRestController` inherit `@CrossOrigin` configuration from their associated repositories.
5556

57+
[[customizing-sdr.configuring-cors.global-config]]
5658
== Global CORS Configuration
5759

5860
In addition to fine-grained, annotation-based configuration, you probably want to define some global CORS configuration as well. This is similar to Spring Web MVC'S CORS configuration but can be declared within Spring Data REST and combined with fine-grained `@CrossOrigin` configuration. By default, all origins and `GET`, `HEAD`, and `POST` methods are allowed.

src/main/asciidoc/configuring-the-rest-url-path.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ interface PersonRepository extends CrudRepository<Person, Long> {
5858

5959
Now the query method in the preceding example is exposed at `http://localhost:8080/people/search/names`.
6060

61+
[[customizing-sdr.configuring-the-rest-url-path.rels]]
6162
== Handling `rel` Attributes
6263

6364
Since these resources are all discoverable, you can also affect how the `rel` attribute is displayed in the links sent out by the exporter.

src/main/asciidoc/custom-jackson-deserialization.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Sometimes, the behavior of the Spring Data REST `ObjectMapper` (which has been s
55

66
To accommodate the largest percentage of the use cases, Spring Data REST tries to render your object graph correctly. It tries to serialize unmanaged beans as normal POJOs, and tries to create links to managed beans where necessary. However, if your domain model does not easily lend itself to reading or writing plain JSON, you may want to configure Jackson's `ObjectMapper` with your own custom type mappings and (de)serializers.
77

8+
[[customizing-sdr.custom-jackson-deserialization.abstract-classes]]
89
== Abstract Class Registration
910

1011
One key configuration point you might need to hook into is when you use an abstract class (or an interface) in your domain model. Jackson does not, by default, know what implementation to create for an interface. Consider the following example:
@@ -46,6 +47,7 @@ public class MyCustomModule extends SimpleModule {
4647

4748
Once you have access to the `SetupContext` object in your `Module`, you can do all sorts of cool things to configure Jackon's JSON mapping. You can read more about how https://wiki.fasterxml.com/JacksonFeatureModules[Modules work on Jackson's wiki].
4849

50+
[[customizing-sdr.custom-jackson-deserialization.custom-serializers]]
4951
== Adding Custom Serializers for Domain Types
5052

5153
If you want to serialize or deserialize a domain type in a special way, you can register your own implementations with Jackson's `ObjectMapper`. Then the Spring Data REST exporter transparently handles those domain objects correctly.

src/main/asciidoc/customizing-json-output.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
Sometimes in your application, you need to provide links to other resources from a particular entity. For example, a `Customer` response might be enriched with links to a current shopping cart or links to manage resources related to that entity. Spring Data REST provides integration with https://github.com/SpringSource/spring-hateoas[Spring HATEOAS] and provides an extension hook that lets you alter the representation of resources that go out to the client.
55

6+
[[customizing-sdr.customizing-json-output.representation-model-processor]]
67
== The `RepresentationModelProcessor` Interface
78

89
Spring HATEOAS defines a `RepresentationModelProcessor<>` interface for processing entities. All beans of type `RepresentationModelProcessor&lt;EntityModel&lt;T&gt;&gt;` are automatically picked up by the Spring Data REST exporter and triggered when serializing an entity of type `T`.
@@ -29,11 +30,12 @@ public RepresentationModelProcessor<EntityModel<Person>> personProcessor() {
2930
====
3031

3132
IMPORTANT: The preceding example hard codes a link to `http://localhost:8080/people`. If you have a Spring MVC endpoint inside your app to which you wish to link, consider using Spring HATEOAS's https://github.com/spring-projects/spring-hateoas#building-links-pointing-to-methods[`linkTo(...)`] method to avoid managing the URL.
32-
33+
[[customizing-sdr.customizing-json-output.adding-links]]
3334
== Adding Links
3435

3536
You can add links to the default representation of an entity by calling `model.add(Link)`, as the preceding example shows. Any links you add to the `EntityModel` are added to the final output.
3637

38+
[[customizing-sdr.customizing-json-output.customizing-representation]]
3739
== Customizing the Representation
3840

3941
The Spring Data REST exporter executes any discovered `RepresentationModelProcessor` instances before it creates the output representation. It does so by registering a `Converter<Entity, EntityModel>` instance with an internal `ConversionService`. This is the component responsible for creating the links to referenced entities (such as those objects under the `_links` property in the object's JSON representation). It takes an `@Entity` and iterates over its properties, creating links for those properties that are managed by a `Repository` and copying across any embedded or simple properties.

src/main/asciidoc/customizing-sdr.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
There are many options to tailor Spring Data REST. These subsections show how.
55

6+
[[customizing-sdr.item-resource-uris]]
67
== Customizing Item Resource URIs
78

89
By default, the URI for item resources are comprised of the path segment used for the collection resource with the database identifier appended.

src/main/asciidoc/events.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class BeforeSaveEventListener extends AbstractRepositoryEventListener {
3737

3838
One thing to note with this approach, however, is that it makes no distinction based on the type of the entity. You have to inspect that yourself.
3939

40+
[[events.annotated-handler]]
4041
== Writing an Annotated Handler
4142

4243
Another approach is to use an annotated handler, which filters events based on domain type.

src/main/asciidoc/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[spring-data-rest-reference]]
22
= Spring Data REST Reference Guide
3-
Jon Brisbin, Oliver Gierke, Greg Turnquist, Jay Bryant
3+
Jon Brisbin, Oliver Drotbohm, Greg Turnquist, Jay Bryant
44
:revnumber: {version}
55
:revdate: {localdate}
66
ifdef::backend-epub3[:front-cover-image: image:epub-cover.png[Front Cover,1050,1600]]

src/main/asciidoc/integration.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
This section details various ways to integrate with Spring Data REST components, whether from a Spring application that is using Spring Data REST or from other means.
66

7+
[[integration.programmatic-links]]
78
== Programmatic Links
89

910
Sometimes you need to add links to exported resources in your own custom-built Spring MVC controllers. There are three basic levels of linking available:

src/main/asciidoc/metadata.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ If you navigate to `/profile/persons` and look at the profile data for a `Person
118118
} ]
119119
}
120120
----
121-
122121
<1> A detailed listing of the attributes of a `Person` resource, identified as `#person-representation`, lists the names
123122
of the attributes.
124123
<2> The supported operations. This one indicates how to create a new `Person`.

0 commit comments

Comments
 (0)