From 823e0d02fcfdc84d67149b94d3848e4780d18a32 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 5 Sep 2023 15:41:22 +0200 Subject: [PATCH] make it beautiful --- .../examples/ReactiveMongoApplication.java | 2 +- src/main/antora/modules/ROOT/nav.adoc | 41 +++++------- .../migration-guide-2.x-to-3.x.adoc | 13 ++-- .../migration-guide-3.x-to-4.x.adoc | 2 +- .../modules/ROOT/pages/mongodb/auditing.adoc | 2 +- .../mongodb/client-session-transactions.adoc | 11 +++- .../ROOT/pages/mongodb/configuration.adoc | 44 ++++++------- .../ROOT/pages/mongodb/mapping/mapping.adoc | 3 +- .../modules/ROOT/pages/mongodb/migrating.adoc | 63 ------------------- .../ROOT/pages/mongodb/mongo-encryption.adoc | 2 +- .../ROOT/pages/mongodb/tailable-cursors.adoc | 2 +- .../ROOT/pages/mongodb/template-api.adoc | 4 +- .../ROOT/pages/mongodb/template-config.adoc | 6 +- 13 files changed, 66 insertions(+), 129 deletions(-) delete mode 100644 src/main/antora/modules/ROOT/pages/mongodb/migrating.adoc diff --git a/src/main/antora/modules/ROOT/examples/ReactiveMongoApplication.java b/src/main/antora/modules/ROOT/examples/ReactiveMongoApplication.java index 7ade8622d..cbb53c590 100644 --- a/src/main/antora/modules/ROOT/examples/ReactiveMongoApplication.java +++ b/src/main/antora/modules/ROOT/examples/ReactiveMongoApplication.java @@ -30,7 +30,7 @@ public class ReactiveMongoApplication { ReactiveMongoOperations mongoOps = new ReactiveMongoTemplate(MongoClients.create(), "database"); - Mono joe = mongoOps.insert(new Person("Joe", 34)) + mongoOps.insert(new Person("Joe", 34)) .then(mongoOps.query(Person.class).matching(where("name").is("Joe")).first()) .doOnNext(System.out::println) .block(); diff --git a/src/main/antora/modules/ROOT/nav.adoc b/src/main/antora/modules/ROOT/nav.adoc index fdea65e6b..96aaa1ff7 100644 --- a/src/main/antora/modules/ROOT/nav.adoc +++ b/src/main/antora/modules/ROOT/nav.adoc @@ -7,8 +7,6 @@ * xref:mongodb.adoc[] ** xref:mongodb/getting-started.adoc[] ** xref:mongodb/configuration.adoc[] - -// Template ** xref:mongodb/template-api.adoc[] *** xref:mongodb/template-config.adoc[] *** xref:mongodb/template-crud-operations.adoc[] @@ -18,10 +16,7 @@ *** xref:mongodb/aggregation-framework.adoc[] *** xref:mongodb/template-collection-management.adoc[] **** xref:mongodb/template-collection-schema.adoc[] -** xref:mongodb/template-gridfs.adoc[] - - -// Mapping +*** xref:mongodb/template-gridfs.adoc[] ** xref:mongodb/mapping/mapping.adoc[] *** xref:mongodb/mapping/custom-conversions.adoc[] *** xref:mongodb/mapping/property-converters.adoc[] @@ -29,7 +24,13 @@ *** xref:mongodb/mapping/document-references.adoc[] *** xref:mongodb/mapping/entity-callbacks.adoc[] *** xref:mongodb/mapping/lifecycle-events.adoc[] +** xref:mongodb/client-session-transactions.adoc[] +** xref:mongodb/change-streams.adoc[] +** xref:mongodb/tailable-cursors.adoc[] +** xref:mongodb/sharding.adoc[] +** xref:mongodb/mongo-encryption.adoc[] ** xref:mongodb/auditing.adoc[] +** xref:mongodb/observability.adoc[] // Repository * xref:repositories.adoc[] @@ -49,14 +50,6 @@ * xref:observability.adoc[] -// Mongo Specifics -** xref:mongodb/client-session-transactions.adoc[] -** xref:mongodb/tailable-cursors.adoc[] -** xref:mongodb/change-streams.adoc[] -** xref:mongodb/observability.adoc[] -** xref:mongodb/sharding.adoc[] -** xref:mongodb/mongo-encryption.adoc[] - * xref:kotlin.adoc[] ** xref:kotlin/requirements.adoc[] ** xref:kotlin/null-safety.adoc[] @@ -66,13 +59,13 @@ // move parts somewhere else -** xref:mongodb/query-by-example.adoc[] -**** xref:mongodb/mongo-query/geo-json.adoc[] -**** xref:mongodb/mongo-query/collation.adoc[] -**** xref:mongodb/mongo-query/kotlin-support.adoc[] -**** xref:mongodb/mongo-query/additional-options.adoc[] - -// still needed??? -*** xref:mongodb/mongo-mapreduce.adoc[] -*** xref:mongodb/mongo-server-side-scripts.adoc[] -*** xref:mongodb/mongo-group.adoc[] +// ** xref:mongodb/query-by-example.adoc[] +// **** xref:mongodb/mongo-query/geo-json.adoc[] +// **** xref:mongodb/mongo-query/collation.adoc[] +// **** xref:mongodb/mongo-query/kotlin-support.adoc[] +// **** xref:mongodb/mongo-query/additional-options.adoc[] +// +// // still needed??? +// *** xref:mongodb/mongo-mapreduce.adoc[] +// *** xref:mongodb/mongo-server-side-scripts.adoc[] +// *** xref:mongodb/mongo-group.adoc[] diff --git a/src/main/antora/modules/ROOT/pages/migration-guide/migration-guide-2.x-to-3.x.adoc b/src/main/antora/modules/ROOT/pages/migration-guide/migration-guide-2.x-to-3.x.adoc index 5771eff54..c002c1fee 100644 --- a/src/main/antora/modules/ROOT/pages/migration-guide/migration-guide-2.x-to-3.x.adoc +++ b/src/main/antora/modules/ROOT/pages/migration-guide/migration-guide-2.x-to-3.x.adoc @@ -1,11 +1,11 @@ [[mongodb.migration.2.x-3.x]] -== Migration Guide from 2.x to 3.x += Migration Guide from 2.x to 3.x Spring Data MongoDB 3.x requires the MongoDB Java Driver 4.x + To learn more about driver versions please visit the https://www.mongodb.com/docs/drivers/java/sync/current/upgrade/[MongoDB Documentation]. [[dependency-changes]] -=== Dependency Changes +== Dependency Changes * `org.mongodb:mongo-java-driver` (uber jar) got replaced with: ** bson-jar @@ -16,7 +16,7 @@ The change in dependencies allows usage of the reactive support without having t NOTE: The new sync driver does no longer support `com.mongodb.DBObject`. Please use `org.bson.Document` instead. [[signature-changes]] -=== Signature Changes +== Signature Changes * `MongoTemplate` no longer supports `com.mongodb.MongoClient` and `com.mongodb.MongoClientOptions`. Please use `com.mongodb.client.MongoClient` and `com.mongodb.MongoClientSettings` instead. @@ -24,18 +24,20 @@ Please use `com.mongodb.client.MongoClient` and `com.mongodb.MongoClientSettings In case you're using `AbstractMongoConfiguration` please switch to `AbstractMongoClientConfiguration`. [[namespace-changes]] -=== Namespace Changes +== Namespace Changes The switch to `com.mongodb.client.MongoClient` requires an update of your configuration XML if you have one. The best way to provide required connection information is by using a connection string. Please see the https://docs.mongodb.com/manual/reference/connection-string/[MongoDB Documentation] for details. -[source,xml] + ==== +[source,xml] ---- ---- +[source,xml] ---- @@ -46,6 +48,7 @@ Please see the https://docs.mongodb.com/manual/reference/connection-string/[Mong connection-string="mongodb://${mongo.host}:${mongo.port}/?replicaSet=rs0" /> ---- +[source,xml] ---- ---- -==== - - -NOTE: Username and password credentials used in XML-based configuration must be URL-encoded when these contain reserved characters, such as `:`, `%`, `@`, or `,`. +Username and password credentials used in XML-based configuration must be URL-encoded when these contain reserved characters, such as `:`, `%`, `@`, or `,`. The following example shows encoded credentials: `m0ng0@dmin:mo_res:bw6},Qsdxx@admin@database` -> `m0ng0%40dmin:mo_res%3Abw6%7D%2CQsdxx%40admin@database` See https://tools.ietf.org/html/rfc3986#section-2.2[section 2.2 of RFC 3986] for further details. +====== If you need to configure additional options on the `com.mongodb.client.MongoClient` instance that is used to create a `SimpleMongoClientDbFactory`, you can refer to an existing bean as shown in the following example. To show another common usage pattern, the following listing shows the use of a property placeholder, which lets you parametrize the configuration and the creation of a `MongoTemplate`: -==== -.Java -[source,java,role="primary"] +[tabs] +====== +Java:: ++ +[source,java,indent=0,subs="verbatim,quotes",role="primary"] ---- @Configuration @PropertySource("classpath:/com/myapp/mongodb/config/mongo.properties") -public class ApplicationContextEventTestsAppConfig extends AbstractMongoClientConfiguration { +public class MongoAppConfig extends AbstractMongoClientConfiguration { @Autowired Environment env; @@ -309,8 +311,9 @@ public class ApplicationContextEventTestsAppConfig extends AbstractMongoClientCo } ---- -.XML -[source,xml,role="secondary"] +XML:: ++ +[source,xml,indent=0,subs="verbatim,quotes",role="secondary"] ---- @@ -330,5 +333,4 @@ public class ApplicationContextEventTestsAppConfig extends AbstractMongoClientCo ---- -==== - +====== diff --git a/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping.adoc b/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping.adoc index 22032ad37..538cf0c95 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping.adoc @@ -1,6 +1,5 @@ - [[mapping-chapter]] -= Mapping += Object Mapping Rich mapping support is provided by the `MappingMongoConverter`. `MappingMongoConverter` has a rich metadata model that provides a full feature set to map domain objects to MongoDB documents. The mapping metadata model is populated by using annotations on your domain objects. diff --git a/src/main/antora/modules/ROOT/pages/mongodb/migrating.adoc b/src/main/antora/modules/ROOT/pages/mongodb/migrating.adoc deleted file mode 100644 index 5c9dd1fea..000000000 --- a/src/main/antora/modules/ROOT/pages/mongodb/migrating.adoc +++ /dev/null @@ -1,63 +0,0 @@ -[[migrating]] -= Migrating - -This chapter coverts major changes and outlines migration steps. - -[[migrating-2.x-to-3.0]] -== 2.x to 3.0 - -[[dependency-changes]] -=== Dependency Changes - -* `org.mongodb:mongo-java-driver` (uber jar) got replaced with: -** bson-jar -** core-jar -** sync-jar - -The change in dependencies allows usage of the reactive support without having to pull the synchronous driver. -NOTE: The new sync driver does no longer support `com.mongodb.DBObject`. Please use `org.bson.Document` instead. - -[[signature-changes]] -=== Signature Changes - -* `MongoTemplate` no longer supports `com.mongodb.MongoClient` and `com.mongodb.MongoClientOptions`. -Please use `com.mongodb.client.MongoClient` and `com.mongodb.MongoClientSettings` instead. - -In case you're using `AbstractMongoConfiguration` please switch to `AbstractMongoClientConfiguration`. - -[[namespace-changes]] -=== Namespace Changes - -The switch to `com.mongodb.client.MongoClient` requires an update of your configuration XML if you have one. -The best way to provide required connection information is by using a connection string. -Please see the https://docs.mongodb.com/manual/reference/connection-string/[MongoDB Documentation] for details. - -[source,xml] -==== ----- - ----- - ----- - - - - - ----- - ----- - - - ----- -==== - - - diff --git a/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc b/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc index 8ae5da69f..6487f39ba 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc @@ -1,5 +1,5 @@ [[mongo.encryption]] -= Client Side Field Level Encryption (CSFLE) += Encryption (CSFLE) Client Side Encryption is a feature that encrypts data in your application before it is sent to MongoDB. We recommend you get familiar with the concepts, ideally from the https://www.mongodb.com/docs/manual/core/csfle/[MongoDB Documentation] to learn more about its capabilities and restrictions before you continue applying Encryption through Spring Data. diff --git a/src/main/antora/modules/ROOT/pages/mongodb/tailable-cursors.adoc b/src/main/antora/modules/ROOT/pages/mongodb/tailable-cursors.adoc index 0cdb50a1e..97433e141 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/tailable-cursors.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/tailable-cursors.adoc @@ -1,6 +1,6 @@ // carry over the old bookmarks to prevent external links from failing [[tailable-cursors]] -= [[mongo.reactive.repositories.infinite-streams]] Infinite Streams with Tailable Cursors += Tailable Cursors By default, MongoDB automatically closes a cursor when the client exhausts all results supplied by the cursor. Closing a cursor on exhaustion turns a stream into a finite stream. For https://docs.mongodb.com/manual/core/capped-collections/[capped collections], diff --git a/src/main/antora/modules/ROOT/pages/mongodb/template-api.adoc b/src/main/antora/modules/ROOT/pages/mongodb/template-api.adoc index 5d8477741..fc2da268b 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/template-api.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/template-api.adoc @@ -1,13 +1,11 @@ [[mongo-template]] -= Introduction to `MongoTemplate` += Template API The `MongoTemplate` and its reactive counterpart class, located in the `org.springframework.data.mongodb.core` package, is the central class of Spring's MongoDB support and provides a rich feature set for interacting with the database. The template offers convenience operations to create, update, delete, and query MongoDB documents and provides a mapping between your domain objects and MongoDB documents. NOTE: Once configured, `MongoTemplate` is thread-safe and can be reused across multiple instances. -== Template API - The `MongoTemplate` class implements the interface `MongoOperations`. In as much as possible, the methods on `MongoOperations` are named after methods available on the MongoDB driver `Collection` object, to make the API familiar to existing MongoDB developers who are used to the driver API. For example, you can find methods such as `find`, `findAndModify`, `findAndReplace`, `findOne`, `insert`, `remove`, `save`, `update`, and `updateMulti`. diff --git a/src/main/antora/modules/ROOT/pages/mongodb/template-config.adoc b/src/main/antora/modules/ROOT/pages/mongodb/template-config.adoc index 5c122576c..22f7588e6 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/template-config.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/template-config.adoc @@ -48,11 +48,11 @@ XML:: + [source,xml,indent=0,subs="verbatim,quotes",role="third"] ---- - + - - + + ---- ======