Skip to content

Commit 093a2cb

Browse files
michal.vich@gmail.comjyemin
authored andcommitted
JAVA-725 Deprecate MongoURI, MongoOptions, and Mongo constructors
1 parent 461c9b8 commit 093a2cb

File tree

3 files changed

+54
-9
lines changed

3 files changed

+54
-9
lines changed

src/main/com/mongodb/Mongo.java

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ public static DB connect( DBAddress addr ){
131131
* Creates a Mongo instance based on a (single) mongodb node (localhost, default port)
132132
* @throws UnknownHostException
133133
* @throws MongoException
134+
*
135+
* @deprecated Replaced by {@link MongoClient#MongoClient()})
136+
*
134137
*/
138+
@Deprecated
135139
public Mongo()
136140
throws UnknownHostException {
137141
this( new ServerAddress() );
@@ -142,7 +146,11 @@ public Mongo()
142146
* @param host server to connect to
143147
* @throws UnknownHostException if the database host cannot be resolved
144148
* @throws MongoException
149+
*
150+
* @deprecated Replaced by {@link MongoClient#MongoClient(String)}
151+
*
145152
*/
153+
@Deprecated
146154
public Mongo( String host )
147155
throws UnknownHostException{
148156
this( new ServerAddress( host ) );
@@ -154,7 +162,11 @@ public Mongo( String host )
154162
* @param options default query options
155163
* @throws UnknownHostException if the database host cannot be resolved
156164
* @throws MongoException
165+
*
166+
* @deprecated Replaced by {@link MongoClient#MongoClient(String, MongoClientOptions)}
167+
*
157168
*/
169+
@Deprecated
158170
public Mongo( String host , MongoOptions options )
159171
throws UnknownHostException {
160172
this( new ServerAddress( host ) , options );
@@ -166,7 +178,11 @@ public Mongo( String host , MongoOptions options )
166178
* @param port the port on which the database is running
167179
* @throws UnknownHostException if the database host cannot be resolved
168180
* @throws MongoException
181+
*
182+
* @deprecated Replaced by {@link MongoClient#MongoClient(String, int)}
183+
*
169184
*/
185+
@Deprecated
170186
public Mongo( String host , int port )
171187
throws UnknownHostException {
172188
this( new ServerAddress( host , port ) );
@@ -176,8 +192,12 @@ public Mongo( String host , int port )
176192
* Creates a Mongo instance based on a (single) mongodb node
177193
* @see com.mongodb.ServerAddress
178194
* @param addr the database address
179-
* @throws MongoException
195+
* @throws MongoException
196+
*
197+
* @deprecated Replaced by {@link MongoClient#MongoClient(ServerAddress)}
198+
*
180199
*/
200+
@Deprecated
181201
public Mongo( ServerAddress addr ) {
182202
this(addr, new MongoOptions());
183203
}
@@ -188,7 +208,11 @@ public Mongo( ServerAddress addr ) {
188208
* @param addr the database address
189209
* @param options default query options
190210
* @throws MongoException
211+
*
212+
* @deprecated Replaced by {@link MongoClient#MongoClient(ServerAddress, MongoClientOptions)}
213+
*
191214
*/
215+
@Deprecated
192216
public Mongo( ServerAddress addr , MongoOptions options ) {
193217
this(MongoAuthority.direct(addr), options);
194218
}
@@ -238,7 +262,11 @@ public Mongo( ServerAddress left , ServerAddress right , MongoOptions options )
238262
* either be a list of mongod servers in the same replica set or a list of mongos servers in the same
239263
* sharded cluster.
240264
* @throws MongoException
265+
*
266+
* @deprecated Replaced by {@link MongoClient#MongoClient(java.util.List)}
267+
*
241268
*/
269+
@Deprecated
242270
public Mongo( List<ServerAddress> seeds ) {
243271
this( seeds , new MongoOptions() );
244272
}
@@ -257,8 +285,12 @@ public Mongo( List<ServerAddress> seeds ) {
257285
* either be a list of mongod servers in the same replica set or a list of mongos servers in the same
258286
* sharded cluster.
259287
* @param options for configuring this Mongo instance
260-
* @throws MongoException
288+
* @throws MongoException
289+
*
290+
* @deprecated Replaced by {@link MongoClient#MongoClient(java.util.List, MongoClientOptions)}
291+
*
261292
*/
293+
@Deprecated
262294
public Mongo( List<ServerAddress> seeds , MongoOptions options ) {
263295
this(MongoAuthority.dynamicSet(seeds), options);
264296
}
@@ -277,8 +309,11 @@ public Mongo( List<ServerAddress> seeds , MongoOptions options ) {
277309
* @throws MongoException
278310
* @throws UnknownHostException
279311
* @dochub connections
312+
*
313+
* @deprecated Replaced by {@link MongoClient#MongoClient(MongoClientURI)}
314+
*
280315
*/
281-
316+
@Deprecated
282317
public Mongo( MongoURI uri ) throws UnknownHostException {
283318
this(getMongoAuthorityFromURI(uri), uri.getOptions());
284319
}
@@ -434,7 +469,7 @@ public List<ServerAddress> getAllAddress() {
434469
* Gets the list of server addresses currently seen by the connector.
435470
* This includes addresses auto-discovered from a replica set.
436471
* @return
437-
* @throws MongoException
472+
* @throws MongoException
438473
*/
439474
public List<ServerAddress> getServerAddressList() {
440475
return _connector.getServerAddressList();
@@ -618,7 +653,7 @@ protected PoolOutputBuffer createNew(){
618653
* Forces the master server to fsync the RAM data to disk
619654
* This is done automatically by the server at intervals, but can be forced for better reliability.
620655
* @param async if true, the fsync will be done asynchronously on the server.
621-
* @return
656+
* @return
622657
* @throws MongoException
623658
*/
624659
public CommandResult fsync(boolean async) {
@@ -632,7 +667,7 @@ public CommandResult fsync(boolean async) {
632667
/**
633668
* Forces the master server to fsync the RAM data to disk, then lock all writes.
634669
* The database will be read-only after this command returns.
635-
* @return
670+
* @return
636671
* @throws MongoException
637672
*/
638673
public CommandResult fsyncAndLock() {
@@ -644,7 +679,7 @@ public CommandResult fsyncAndLock() {
644679
/**
645680
* Unlocks the database, allowing the write operations to go through.
646681
* This command may be asynchronous on the server, which means there may be a small delay before the database becomes writable.
647-
* @return
682+
* @return
648683
* @throws MongoException
649684
*/
650685
public DBObject unlock() {
@@ -655,7 +690,7 @@ public DBObject unlock() {
655690

656691
/**
657692
* Returns true if the database is locked (read-only), false otherwise.
658-
* @return
693+
* @return
659694
* @throws MongoException
660695
*/
661696
public boolean isLocked() {
@@ -716,7 +751,7 @@ String _toKey( MongoURI uri ){
716751
buf.append( uri.getUsername() );
717752
return buf.toString();
718753
}
719-
754+
720755
public static Holder singleton() { return _default; }
721756

722757
private static Holder _default = new Holder();

src/main/com/mongodb/MongoOptions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@
2929
*/
3030
public class MongoOptions {
3131

32+
@Deprecated
3233
public MongoOptions(){
3334
reset();
3435
}
3536

37+
/**
38+
* @deprecated Replaced by {@link MongoClientOptions}
39+
*/
40+
@Deprecated
3641
public MongoOptions(final MongoClientOptions options) {
3742
connectionsPerHost = options.getConnectionsPerHost();
3843
threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier();

src/main/com/mongodb/MongoURI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,17 @@ public class MongoURI {
132132
* Creates a MongoURI from a string.
133133
* @param uri the URI
134134
* @dochub connections
135+
*
136+
* @deprecated Replaced by {@link MongoClientURI#MongoClientURI(String)}
137+
*
135138
*/
139+
@Deprecated
136140
public MongoURI( String uri ) {
137141
this.mongoClientURI = new MongoClientURI(uri, new MongoClientOptions.Builder().legacyDefaults());
138142
mongoOptions = new MongoOptions(mongoClientURI.getOptions());
139143
}
140144

145+
@Deprecated
141146
public MongoURI(final MongoClientURI mongoClientURI) {
142147
this.mongoClientURI = mongoClientURI;
143148
mongoOptions = new MongoOptions(mongoClientURI.getOptions());

0 commit comments

Comments
 (0)