Skip to content

Commit 3a6b04d

Browse files
committed
Make reference to XML namespace optional.
Not all modules have a XML namespace. Therefore it is now possible to exclude parts that reference the XML namespace from the documentation By default the parts referring to the XML namespace are included just as before. But they will get skipped if the `index.adoc` of the module defines the attribute `include-xml-namespaces` as `false` by including ``` :include-xml-namespaces: false ``` Closes #2662 See spring-projects/spring-data-relational#1290 Original pull request #2664
1 parent 0a67a14 commit 3a6b04d

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/main/asciidoc/repositories.adoc

+27-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ _Spring Data repository documentation and your module_
1313
This chapter explains the core concepts and interfaces of Spring Data repositories.
1414
The information in this chapter is pulled from the Spring Data Commons module.
1515
It uses the configuration and code samples for the Java Persistence API (JPA) module.
16-
You should adapt the XML namespace declaration and the types to be extended to the equivalents of the particular module that you use. "`<<repositories.namespace-reference>>`" covers XML configuration, which is supported across all Spring Data modules that support the repository API. "`<<repository-query-keywords>>`" covers the query method keywords supported by the repository abstraction in general.
16+
ifeval::[{include-xml-namespaces} != false]
17+
You should adapt the XML namespace declaration and the types to be extended to the equivalents of the particular module that you use. "`<<repositories.namespace-reference>>`" covers XML configuration, which is supported across all Spring Data modules that support the repository API.
18+
endif::[]
19+
"`<<repository-query-keywords>>`" covers the query method keywords supported by the repository abstraction in general.
1720
For detailed information on the specific features of your module, see the chapter on that module of this document.
1821
====
1922

@@ -154,6 +157,7 @@ class Config { … }
154157
----
155158
====
156159

160+
ifeval::[{include-xml-namespaces} != false]
157161
.. To use XML configuration, define a bean similar to the following:
158162
+
159163
====
@@ -177,8 +181,9 @@ class Config { … }
177181
The JPA namespace is used in this example.
178182
If you use the repository abstraction for any other store, you need to change this to the appropriate namespace declaration of your store module.
179183
In other words, you should exchange `jpa` in favor of, for example, `mongodb`.
184+
endif::[]
180185
+
181-
Also, note that the JavaConfig variant does not configure a package explicitly, because the package of the annotated class is used by default.
186+
Note that the JavaConfig variant does not configure a package explicitly, because the package of the annotated class is used by default.
182187
To customize the package to scan, use one of the `basePackage…` attributes of the data-store-specific repository's `@Enable${store}Repositories`-annotation.
183188
. Inject the repository instance and use it, as shown in the following example:
184189
+
@@ -397,7 +402,9 @@ The next section describes the available options.
397402
=== Query Lookup Strategies
398403

399404
The following strategies are available for the repository infrastructure to resolve the query.
405+
ifeval::[{include-xml-namespaces} != false]
400406
With XML configuration, you can configure the strategy at the namespace through the `query-lookup-strategy` attribute.
407+
endif::[]
401408
For Java configuration, you can use the `queryLookupStrategy` attribute of the `Enable${store}Repositories` annotation.
402409
Some strategies may not be supported for particular datastores.
403410

@@ -878,9 +885,13 @@ ListenableFuture<User> findOneByLastname(String lastname); <3>
878885
[[repositories.create-instances]]
879886
== Creating Repository Instances
880887

881-
This section covers how to create instances and bean definitions for the defined repository interfaces. One way to do so is by using the Spring namespace that is shipped with each Spring Data module that supports the repository mechanism, although we generally recommend using Java configuration.
888+
This section covers how to create instances and bean definitions for the defined repository interfaces.
889+
ifeval::[{include-xml-namespaces} != false]
890+
One way to do so is by using the Spring namespace that is shipped with each Spring Data module that supports the repository mechanism, although we generally recommend using Java configuration.
891+
endif::[]
882892

883893
[[repositories.create-instances.spring]]
894+
ifeval::[{include-xml-namespaces} != false]
884895
=== XML Configuration
885896

886897
Each Spring Data module includes a `repositories` element that lets you define a base package that Spring scans for you, as shown in the following example:
@@ -932,6 +943,7 @@ For example, to exclude certain interfaces from instantiation as repository bean
932943
====
933944

934945
The preceding example excludes all interfaces ending in `SomeRepository` from being instantiated.
946+
endif::[]
935947

936948
[[repositories.create-instances.java-config]]
937949
=== Java Configuration
@@ -1124,9 +1136,15 @@ interface PersonRepository extends CrudRepository<Person, Long>, CustomizedSave<
11241136
[[repositories.configuration]]
11251137
==== Configuration
11261138

1127-
If you use namespace configuration, the repository infrastructure tries to autodetect custom implementation fragments by scanning for classes below the package in which it found a repository.
1128-
These classes need to follow the naming convention of appending the namespace element's `repository-impl-postfix` attribute to the fragment interface name.
1139+
The repository infrastructure tries to autodetect custom implementation fragments by scanning for classes below the package in which it found a repository.
1140+
These classes need to follow the naming convention of appending
1141+
ifeval::[{include-xml-namespaces} != false]
1142+
the namespace element's `repository-impl-postfix` attribute to the fragment interface name.
11291143
This postfix defaults to `Impl`.
1144+
endif::[]
1145+
ifeval::[{include-xml-namespaces} == false]
1146+
`Impl` to the fragment interface name.
1147+
endif::[]
11301148
The following example shows a repository that uses the default postfix and a repository that sets a custom value for the postfix:
11311149

11321150
.Configuration example
@@ -1244,6 +1262,7 @@ class ApplicationConfiguration { … }
12441262
----
12451263
====
12461264

1265+
ifeval::[{include-xml-namespaces} != false]
12471266
A corresponding attribute is available in the XML namespace, as shown in the following example:
12481267

12491268
.Configuring a custom repository base class using XML
@@ -1254,6 +1273,7 @@ A corresponding attribute is available in the XML namespace, as shown in the fol
12541273
base-class="….MyRepositoryImpl" />
12551274
----
12561275
====
1276+
endif::[]
12571277

12581278
[[core.domain-events]]
12591279
== Publishing Events from Aggregate Roots
@@ -1697,6 +1717,7 @@ interface UserRepository extends CrudRepository<User, String>,
16971717

16981718
TIP: You can register a `QuerydslBinderCustomizerDefaults` bean holding default Querydsl bindings before applying specific bindings from the repository or `@QuerydslPredicate`.
16991719

1720+
ifeval::[{include-xml-namespaces} != false]
17001721
[[core.repository-populators]]
17011722
=== Repository Populators
17021723

@@ -1774,3 +1795,4 @@ The following example shows how to unmarshall a repository populator with JAXB:
17741795
</beans>
17751796
----
17761797
====
1798+
endif::[]

0 commit comments

Comments
 (0)