Skip to content

Commit 0de4bed

Browse files
DATAMONGO-1176 - Cleanup.
- Update licenses headers. - Renname variables and methods from dbo -> document. - Remove deprecations. - Remove unused code blocks. - Upgrade to MongoDB Java Driver 3.3
1 parent e912e50 commit 0de4bed

File tree

129 files changed

+709
-1194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+709
-1194
lines changed

spring-data-mongodb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<properties>
1919
<objenesis>1.3</objenesis>
2020
<equalsverifier>1.5</equalsverifier>
21-
<mongo>3.2.2</mongo>
21+
<mongo>3.3.0</mongo>
2222
</properties>
2323

2424
<dependencies>

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/BulkOperations.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.springframework.data.mongodb.core.query.Update;
2222
import org.springframework.data.util.Pair;
2323

24+
import com.mongodb.bulk.BulkWriteResult;
25+
2426
/**
2527
* Bulk operations for insert/update/remove actions on a collection. These bulks operation are available since MongoDB
2628
* 2.6 and make use of low level bulk commands on the protocol level. This interface defines a fluent API to add
@@ -36,7 +38,7 @@ public interface BulkOperations {
3638
/**
3739
* Mode for bulk operation.
3840
**/
39-
public enum BulkMode {
41+
enum BulkMode {
4042

4143
/** Perform bulk operations in sequence. The first error will cancel processing. */
4244
ORDERED,
@@ -139,5 +141,5 @@ public enum BulkMode {
139141
* @return Result of the bulk operation providing counters for inserts/updates etc.
140142
* @throws {@link BulkOperationException} if an error occurred during bulk processing.
141143
*/
142-
com.mongodb.bulk.BulkWriteResult execute();
144+
BulkWriteResult execute();
143145
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionCallback.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2011 the original author or authors.
2+
* Copyright 2010-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,8 +21,24 @@
2121
import com.mongodb.MongoException;
2222
import com.mongodb.client.MongoCollection;
2323

24+
/**
25+
* Callback interface for executing actions against a {@link MongoCollection}
26+
*
27+
* @author Mark Pollak
28+
* @author Grame Rocher
29+
* @author Oliver Gierke
30+
* @author John Brisbin
31+
* @auhtor Christoph Strobl
32+
* @since 1.0
33+
*/
2434
public interface CollectionCallback<T> {
2535

36+
/**
37+
* @param collection never {@literal null}.
38+
* @return
39+
* @throws MongoException
40+
* @throws DataAccessException
41+
*/
2642
T doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException;
2743

2844
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CursorPreparer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,13 +17,13 @@
1717

1818
import org.bson.Document;
1919

20-
import com.mongodb.DBCursor;
2120
import com.mongodb.client.FindIterable;
2221

2322
/**
24-
* Simple callback interface to allow customization of a {@link DBCursor}.
23+
* Simple callback interface to allow customization of a {@link FindIterable}.
2524
*
2625
* @author Oliver Gierke
26+
* @author Christoph Strobl
2727
*/
2828
interface CursorPreparer {
2929

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DbCallback.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2011 the original author or authors.
2+
* Copyright 2010-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,10 @@
2020
import com.mongodb.MongoException;
2121
import com.mongodb.client.MongoDatabase;
2222

23+
/**
24+
*
25+
* @param <T>
26+
*/
2327
public interface DbCallback<T> {
2428

2529
T doInDB(MongoDatabase db) throws MongoException, DataAccessException;

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultBulkOperations.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
*
4444
* @author Tobias Trelle
4545
* @author Oliver Gierke
46+
* @author Christoph Strobl
4647
* @since 1.9
4748
*/
4849
class DefaultBulkOperations implements BulkOperations {
4950

5051
private final MongoOperations mongoOperations;
5152
private final BulkMode bulkMode;
5253
private final String collectionName;
53-
private final Class<?> entityType;
5454

5555
private PersistenceExceptionTranslator exceptionTranslator;
5656
private WriteConcernResolver writeConcernResolver;
@@ -79,7 +79,6 @@ class DefaultBulkOperations implements BulkOperations {
7979
this.mongoOperations = mongoOperations;
8080
this.bulkMode = bulkMode;
8181
this.collectionName = collectionName;
82-
this.entityType = entityType;
8382

8483
this.exceptionTranslator = new MongoExceptionTranslator();
8584
this.writeConcernResolver = DefaultWriteConcernResolver.INSTANCE;
@@ -237,8 +236,6 @@ public BulkOperations remove(Query query) {
237236
Assert.notNull(query, "Query must not be null!");
238237

239238
models.add(new DeleteManyModel<Document>(query.getQueryObject()));
240-
// bulk.find(query.getQueryObject()).remove();
241-
242239
return this;
243240
}
244241

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2015 the original author or authors.
2+
* Copyright 2011-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -86,9 +86,6 @@ public Object doInCollection(MongoCollection<Document> collection) throws MongoE
8686
if (indexOptions.containsKey("unique")) {
8787
ops = ops.unique((Boolean) indexOptions.get("unique"));
8888
}
89-
// if(indexOptions.containsField("dropDuplicates")) {
90-
// ops = ops.((boolean)indexOptions.get("dropDuplicates"));
91-
// }
9289
if (indexOptions.containsKey("sparse")) {
9390
ops = ops.sparse((Boolean) indexOptions.get("sparse"));
9491
}
@@ -151,22 +148,6 @@ public void dropAllIndexes() {
151148
dropIndex("*");
152149
}
153150

154-
/*
155-
* (non-Javadoc)
156-
* @see org.springframework.data.mongodb.core.IndexOperations#resetIndexCache()
157-
*/
158-
@Deprecated
159-
public void resetIndexCache() {
160-
mongoOperations.execute(collectionName, new CollectionCallback<Void>() {
161-
public Void doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException {
162-
163-
// TODO remove this one
164-
// ReflectiveDBCollectionInvoker.resetIndexCache(collection);
165-
return null;
166-
}
167-
});
168-
}
169-
170151
/*
171152
* (non-Javadoc)
172153
* @see org.springframework.data.mongodb.core.IndexOperations#getIndexInfo()
@@ -177,25 +158,25 @@ public List<IndexInfo> getIndexInfo() {
177158
public List<IndexInfo> doInCollection(MongoCollection<Document> collection)
178159
throws MongoException, DataAccessException {
179160

180-
MongoCursor<Document> dbObjectList = collection.listIndexes(Document.class).iterator();
181-
return getIndexData(dbObjectList);
161+
MongoCursor<Document> cursor = collection.listIndexes(Document.class).iterator();
162+
return getIndexData(cursor);
182163
}
183164

184-
private List<IndexInfo> getIndexData(MongoCursor<Document> dbObjectList) {
165+
private List<IndexInfo> getIndexData(MongoCursor<Document> cursor) {
185166

186167
List<IndexInfo> indexInfoList = new ArrayList<IndexInfo>();
187168

188-
while (dbObjectList.hasNext()) {
169+
while (cursor.hasNext()) {
189170

190-
Document ix = dbObjectList.next();
191-
Document keyDbObject = (Document) ix.get("key");
192-
int numberOfElements = keyDbObject.keySet().size();
171+
Document ix = cursor.next();
172+
Document keyDocument = (Document) ix.get("key");
173+
int numberOfElements = keyDocument.keySet().size();
193174

194175
List<IndexField> indexFields = new ArrayList<IndexField>(numberOfElements);
195176

196-
for (String key : keyDbObject.keySet()) {
177+
for (String key : keyDocument.keySet()) {
197178

198-
Object value = keyDbObject.get(key);
179+
Object value = keyDocument.get(key);
199180

200181
if (TWO_D_IDENTIFIERS.contains(value)) {
201182
indexFields.add(IndexField.geo(key));

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DocumentCallbackHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2011 the original author or authors.
2+
* Copyright 2010-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,8 +28,13 @@
2828
* later inspection.
2929
*
3030
* @author Mark Pollack
31+
* @author Grame Rocher
32+
* @author Oliver Gierke
33+
* @author John Brisbin
34+
* @author Christoph Strobl
35+
* @since 1.0
3136
*/
3237
public interface DocumentCallbackHandler {
3338

34-
void processDocument(Document dbObject) throws MongoException, DataAccessException;
39+
void processDocument(Document document) throws MongoException, DataAccessException;
3540
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/GeoCommandStatistics.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* Value object to mitigate different representations of geo command execution results in MongoDB.
2323
*
2424
* @author Oliver Gierke
25+
* @author Christoph Strobl
2526
* @soundtrack Fruitcake - Jeff Coffin (The Inside of the Outside)
27+
* @since 1.9
2628
*/
2729
class GeoCommandStatistics {
2830

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/IndexOperations.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2015 the original author or authors.
2+
* Copyright 2011-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,15 +49,6 @@ public interface IndexOperations {
4949
*/
5050
void dropAllIndexes();
5151

52-
/**
53-
* Clears all indices that have not yet been applied to this collection.
54-
*
55-
* @deprecated since 1.7. The MongoDB Java driver version 3.0 does no longer support reseting the index cache.
56-
* @throws {@link UnsupportedOperationException} when used with MongoDB Java driver version 3.0.
57-
*/
58-
@Deprecated
59-
void resetIndexCache();
60-
6152
/**
6253
* Returns the index information on the collection.
6354
*

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAction.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2012 the original author or authors.
2+
* Copyright 2011-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
*
3232
* @author Mark Pollack
3333
* @author Oliver Gierke
34+
* @author Christoph Strobl
3435
*/
3536
public class MongoAction {
3637

@@ -72,14 +73,6 @@ public WriteConcern getDefaultWriteConcern() {
7273
return defaultWriteConcern;
7374
}
7475

75-
/**
76-
* @deprecated use {@link #getEntityType()} instead.
77-
*/
78-
@Deprecated
79-
public Class<?> getEntityClass() {
80-
return entityType;
81-
}
82-
8376
public Class<?> getEntityType() {
8477
return entityType;
8578
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoExceptionTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2015 the original author or authors.
2+
* Copyright 2010-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2015 the original author or authors.
2+
* Copyright 2011-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,18 +84,6 @@ public interface MongoOperations {
8484
*/
8585
Document executeCommand(Document command);
8686

87-
/**
88-
* Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO
89-
* exception hierarchy.
90-
*
91-
* @param command a MongoDB command
92-
* @param options query options to use
93-
* @deprecated since 1.7. Please use {@link #executeCommand(Document, ReadPreference)}, as the MongoDB Java driver
94-
* version 3 no longer supports this operation.
95-
*/
96-
@Deprecated
97-
Document executeCommand(Document command, int options);
98-
9987
/**
10088
* Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's data
10189
* access exception hierarchy.
@@ -152,22 +140,6 @@ public interface MongoOperations {
152140
*/
153141
<T> T execute(String collectionName, CollectionCallback<T> action);
154142

155-
/**
156-
* Executes the given {@link DbCallback} within the same connection to the database so as to ensure consistency in a
157-
* write heavy environment where you may read the data that you wrote. See the comments on {@see <a
158-
* href=http://www.mongodb.org/display/DOCS/Java+Driver+Concurrency>Java Driver Concurrency</a>}
159-
* <p/>
160-
* Allows for returning a result object, that is a domain object or a collection of domain objects.
161-
*
162-
* @param <T> return type
163-
* @param action callback that specified the MongoDB actions to perform on the DB instance
164-
* @return a result object returned by the action or <tt>null</tt>
165-
* @deprecated since 1.7 as the MongoDB Java driver version 3 does not longer support request boundaries via
166-
* {@link DB#requestStart()} and {@link DB#requestDone()}.
167-
*/
168-
@Deprecated
169-
<T> T executeInSession(DbCallback<T> action);
170-
171143
/**
172144
* Executes the given {@link Query} on the entity collection of the specified {@code entityType} backed by a Mongo DB
173145
* {@link Cursor}.

0 commit comments

Comments
 (0)