Skip to content

Commit d19de19

Browse files
authored
Document that CodecRegistry instances configured by the application a… (#1020)
JAVA-4777
1 parent f5a84d3 commit d19de19

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

driver-core/src/main/com/mongodb/MongoClientSettings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,15 @@ public Builder credential(final MongoCredential credential) {
400400
/**
401401
* Sets the codec registry
402402
*
403+
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
404+
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
405+
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
406+
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
407+
*
403408
* @param codecRegistry the codec registry
404409
* @return this
405410
* @see MongoClientSettings#getCodecRegistry()
411+
* @see org.bson.codecs.configuration.CodecRegistries
406412
*/
407413
public Builder codecRegistry(final CodecRegistry codecRegistry) {
408414
this.codecRegistry = notNull("codecRegistry", codecRegistry);

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MongoCollection.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,14 @@ public interface MongoCollection<TDocument> {
118118
/**
119119
* Create a new MongoCollection instance with a different codec registry.
120120
*
121+
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
122+
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
123+
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
124+
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
125+
*
121126
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the collection
122127
* @return a new MongoCollection instance with the different codec registry
128+
* @see org.bson.codecs.configuration.CodecRegistries
123129
*/
124130
MongoCollection<TDocument> withCodecRegistry(CodecRegistry codecRegistry);
125131

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MongoDatabase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,14 @@ public interface MongoDatabase {
7777
/**
7878
* Create a new MongoDatabase instance with a different codec registry.
7979
*
80+
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
81+
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
82+
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
83+
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
84+
*
8085
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the collection
8186
* @return a new MongoDatabase instance with the different codec registry
87+
* @see org.bson.codecs.configuration.CodecRegistries
8288
*/
8389
MongoDatabase withCodecRegistry(CodecRegistry codecRegistry);
8490

driver-scala/src/main/scala/org/mongodb/scala/MongoCollection.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,15 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
9696
/**
9797
* Create a new MongoCollection instance with a different codec registry.
9898
*
99+
* The { @link CodecRegistry} configured by this method is effectively treated by the driver as an
100+
* instance of { @link CodecProvider}, which { @link CodecRegistry} extends.
101+
* So there is no benefit to defining a class that implements { @link CodecRegistry}. Rather, an
102+
* application should always create { @link CodecRegistry} instances using the factory methods in
103+
* { @link CodecRegistries}.
104+
*
99105
* @param codecRegistry the new { @link org.bson.codecs.configuration.CodecRegistry} for the collection
100106
* @return a new MongoCollection instance with the different codec registry
107+
* @see CodecRegistries
101108
*/
102109
def withCodecRegistry(codecRegistry: CodecRegistry): MongoCollection[TResult] =
103110
MongoCollection(wrapped.withCodecRegistry(codecRegistry))

driver-scala/src/main/scala/org/mongodb/scala/MongoDatabase.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,15 @@ case class MongoDatabase(private[scala] val wrapped: JMongoDatabase) {
7272
/**
7373
* Create a new MongoDatabase instance with a different codec registry.
7474
*
75+
* The { @link CodecRegistry} configured by this method is effectively treated by the driver as an
76+
* instance of { @link CodecProvider}, which { @link CodecRegistry} extends.
77+
* So there is no benefit to defining a class that implements { @link CodecRegistry}. Rather, an
78+
* application should always create { @link CodecRegistry} instances using the factory methods in
79+
* { @link CodecRegistries}.
80+
*
7581
* @param codecRegistry the new { @link org.bson.codecs.configuration.CodecRegistry} for the collection
7682
* @return a new MongoDatabase instance with the different codec registry
83+
* @see CodecRegistries
7784
*/
7885
def withCodecRegistry(codecRegistry: CodecRegistry): MongoDatabase =
7986
MongoDatabase(wrapped.withCodecRegistry(codecRegistry))

driver-sync/src/main/com/mongodb/client/MongoCollection.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,14 @@ public interface MongoCollection<TDocument> {
123123
/**
124124
* Create a new MongoCollection instance with a different codec registry.
125125
*
126+
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
127+
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
128+
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
129+
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
130+
*
126131
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the collection
127132
* @return a new MongoCollection instance with the different codec registry
133+
* @see org.bson.codecs.configuration.CodecRegistries
128134
*/
129135
MongoCollection<TDocument> withCodecRegistry(CodecRegistry codecRegistry);
130136

driver-sync/src/main/com/mongodb/client/MongoDatabase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,14 @@ public interface MongoDatabase {
7979
/**
8080
* Create a new MongoDatabase instance with a different codec registry.
8181
*
82+
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
83+
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
84+
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
85+
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
86+
*
8287
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the database
8388
* @return a new MongoDatabase instance with the different codec registry
89+
* @see org.bson.codecs.configuration.CodecRegistries
8490
*/
8591
MongoDatabase withCodecRegistry(CodecRegistry codecRegistry);
8692

0 commit comments

Comments
 (0)