16
16
package org .springframework .data .mongodb ;
17
17
18
18
import reactor .core .publisher .Mono ;
19
-
20
- import org .jspecify .annotations .Nullable ;
21
19
import reactor .util .context .Context ;
22
20
21
+ import org .jspecify .annotations .Nullable ;
23
22
import org .springframework .transaction .NoTransactionException ;
24
23
import org .springframework .transaction .reactive .ReactiveResourceSynchronization ;
25
24
import org .springframework .transaction .reactive .TransactionSynchronization ;
36
35
/**
37
36
* Helper class for managing reactive {@link MongoDatabase} instances via {@link ReactiveMongoDatabaseFactory}. Used for
38
37
* obtaining {@link ClientSession session bound} resources, such as {@link MongoDatabase} and {@link MongoCollection}
39
- * suitable for transactional usage.
40
- * <br />
38
+ * suitable for transactional usage. <br />
41
39
* <strong>Note:</strong> Intended for internal usage only.
42
40
*
43
41
* @author Mark Paluch
@@ -75,8 +73,7 @@ public static Mono<Boolean> isTransactionActive(ReactiveMongoDatabaseFactory dat
75
73
76
74
/**
77
75
* Obtain the default {@link MongoDatabase database} form the given {@link ReactiveMongoDatabaseFactory factory} using
78
- * {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
79
- * <br />
76
+ * {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}. <br />
80
77
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
81
78
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
82
79
*
@@ -104,12 +101,12 @@ public static Mono<MongoDatabase> getDatabase(ReactiveMongoDatabaseFactory facto
104
101
105
102
/**
106
103
* Obtain the {@link MongoDatabase database} with given name form the given {@link ReactiveMongoDatabaseFactory
107
- * factory} using {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
108
- * <br />
104
+ * factory} using {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}. <br />
109
105
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
110
106
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
111
107
*
112
- * @param dbName the name of the {@link MongoDatabase} to get.
108
+ * @param dbName the name of the {@link MongoDatabase} to get. If {@literal null} the default database of the
109
+ * {@link ReactiveMongoDatabaseFactory}.
113
110
* @param factory the {@link ReactiveMongoDatabaseFactory} to get the {@link MongoDatabase} from.
114
111
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
115
112
*/
@@ -119,17 +116,17 @@ public static Mono<MongoDatabase> getDatabase(@Nullable String dbName, ReactiveM
119
116
120
117
/**
121
118
* Obtain the {@link MongoDatabase database} with given name form the given {@link ReactiveMongoDatabaseFactory
122
- * factory}.
123
- * <br />
119
+ * factory}. <br />
124
120
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
125
121
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
126
122
*
127
- * @param dbName the name of the {@link MongoDatabase} to get.
123
+ * @param dbName the name of the {@link MongoDatabase} to get. If {@literal null} the default database of the *
124
+ * {@link ReactiveMongoDatabaseFactory}.
128
125
* @param factory the {@link ReactiveMongoDatabaseFactory} to get the {@link MongoDatabase} from.
129
126
* @param sessionSynchronization the synchronization to use. Must not be {@literal null}.
130
127
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
131
128
*/
132
- public static Mono <MongoDatabase > getDatabase (String dbName , ReactiveMongoDatabaseFactory factory ,
129
+ public static Mono <MongoDatabase > getDatabase (@ Nullable String dbName , ReactiveMongoDatabaseFactory factory ,
133
130
SessionSynchronization sessionSynchronization ) {
134
131
return doGetMongoDatabase (dbName , factory , sessionSynchronization );
135
132
}
0 commit comments