Skip to content

Commit

Permalink
Add documentation for configuring a StoreResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcwarren committed May 28, 2020
1 parent cd1da1d commit 2413718
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
13 changes: 1 addition & 12 deletions spring-content-rest/src/main/asciidoc/rest-index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,4 @@ include::rest-cors.adoc[leveloffset=+1]
include::rest-baseuri.adoc[leveloffset=+1]
include::rest-linkrel.adoc[leveloffset=+1]
include::rest-fullyqualifiedlinks.adoc[leveloffset=+1]
//[[appendix]]
//= Appendix

//:numbered!:
// :leveloffset: +1
// include::{spring-data-commons-docs}/repository-namespace-reference.adoc[]
// include::{spring-data-commons-docs}/repository-populator-namespace-reference.adoc[]
// include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[]
// include::{spring-data-commons-docs}/repository-query-return-types-reference.adoc[]
// include::faq.adoc[]
// include::glossary.adoc[]
// :leveloffset: -1
include::rest-storeresolver.adoc[leveloffset=+1]
33 changes: 33 additions & 0 deletions spring-content-rest/src/main/asciidoc/rest-storeresolver.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
== Store Resolver
Every REST request must map to one store and one store only. However, it is entirely possible to define an application
with multiple stores that make this impossible.

For these situations you need to provide a `StoreResolver` that, based on runtime context, can resolve these conflicts.

.Configuring a StoreResolver
====
[source, java]
----
@Configuration
@EnableS3Stores
public static class ApplicationConfig {
@Bean
public ContentRestConfigurer contentRestConfigurer() {
return new ContentRestConfigurer() {
@Override
public void configure(RestConfiguration config) {
config.addStoreResolver("examples", new StoreResolver() { <1>
@Override
public StoreInfo resolve(StoreInfo... stores) {
/* your resolver implementation */
}
});
}
};
}
}
----
<1> This store resolver resolves conflicts for stores exported through the path "examples"
====

Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public FileSystemResourceLoader fileSystemResourceLoader() throws IOException {
return new FileSystemResourceLoader(Files.createTempDirectory("").toFile().getAbsolutePath());
}

@Bean
public ContentRestConfigurer contentRestConfigurer() {
@Bean
public ContentRestConfigurer contentRestConfigurer() {
return new ContentRestConfigurer() {
@Override
public void configure(RestConfiguration config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class StoreResolverRestConfigurationIT {
tEntity = new Application.TEntity();
tEntity = repo.save(tEntity);
});
It("should return the content with 200 OK", () -> {
It("should return the content from the correct store", () -> {

assertThat(jpaStore, is(not(nullValue())));
assertThat(fsStore, is(not(nullValue())));
Expand Down

0 comments on commit 2413718

Please sign in to comment.