Migrate off SLF4J to Spring JCL.
Closes #3881 Original Pull Request #3883
This commit is contained in:
committed by
Christoph Strobl
parent
0c37a20a0b
commit
f7cbd4264a
@@ -237,13 +237,6 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>${slf4j}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.jqno.equalsverifier</groupId>
|
||||
<artifactId>equalsverifier</artifactId>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.data.util.Version;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.mongodb.MongoDriverInformation;
|
||||
*/
|
||||
public class SpringDataMongoDB {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SpringDataMongoDB.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(SpringDataMongoDB.class);
|
||||
|
||||
private static final Version FALLBACK_VERSION = new Version(3);
|
||||
private static final MongoDriverInformation DRIVER_INFORMATION = MongoDriverInformation
|
||||
@@ -68,7 +68,7 @@ public class SpringDataMongoDB {
|
||||
try {
|
||||
return Version.parse(versionString);
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Cannot read Spring Data MongoDB version '{}'.", versionString);
|
||||
LOGGER.debug(String.format("Cannot read Spring Data MongoDB version '%s'.", versionString));
|
||||
}
|
||||
|
||||
return FALLBACK_VERSION;
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.net.UnknownHostException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -43,8 +43,8 @@ public class ServerAddressPropertyEditor extends PropertyEditorSupport {
|
||||
* A port is a number without a leading 0 at the end of the address that is proceeded by just a single :.
|
||||
*/
|
||||
private static final String HOST_PORT_SPLIT_PATTERN = "(?<!:):(?=[123456789]\\d*$)";
|
||||
private static final String COULD_NOT_PARSE_ADDRESS_MESSAGE = "Could not parse address {} '{}'. Check your replica set configuration!";
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServerAddressPropertyEditor.class);
|
||||
private static final String COULD_NOT_PARSE_ADDRESS_MESSAGE = "Could not parse address %s '%s'. Check your replica set configuration!";
|
||||
private static final Log LOG = LogFactory.getLog(ServerAddressPropertyEditor.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -88,14 +88,14 @@ public class ServerAddressPropertyEditor extends PropertyEditorSupport {
|
||||
private ServerAddress parseServerAddress(String source) {
|
||||
|
||||
if (!StringUtils.hasText(source)) {
|
||||
LOG.warn(COULD_NOT_PARSE_ADDRESS_MESSAGE, "source", source);
|
||||
LOG.warn(String.format(COULD_NOT_PARSE_ADDRESS_MESSAGE, "source", source));
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] hostAndPort = extractHostAddressAndPort(source.trim());
|
||||
|
||||
if (hostAndPort.length > 2) {
|
||||
LOG.warn(COULD_NOT_PARSE_ADDRESS_MESSAGE, "source", source);
|
||||
LOG.warn(String.format(COULD_NOT_PARSE_ADDRESS_MESSAGE, "source", source));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@ public class ServerAddressPropertyEditor extends PropertyEditorSupport {
|
||||
|
||||
return port == null ? new ServerAddress(hostAddress) : new ServerAddress(hostAddress, port);
|
||||
} catch (UnknownHostException e) {
|
||||
LOG.warn(COULD_NOT_PARSE_ADDRESS_MESSAGE, "host", hostAndPort[0]);
|
||||
LOG.warn(String.format(COULD_NOT_PARSE_ADDRESS_MESSAGE, "host", hostAndPort[0]));
|
||||
} catch (NumberFormatException e) {
|
||||
LOG.warn(COULD_NOT_PARSE_ADDRESS_MESSAGE, "port", hostAndPort[1]);
|
||||
LOG.warn(String.format(COULD_NOT_PARSE_ADDRESS_MESSAGE, "port", hostAndPort[1]));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -24,10 +24,10 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.bson.conversions.Bson;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -163,7 +163,7 @@ import com.mongodb.client.result.UpdateResult;
|
||||
*/
|
||||
public class MongoTemplate implements MongoOperations, ApplicationContextAware, IndexOperationsProvider {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MongoTemplate.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(MongoTemplate.class);
|
||||
private static final WriteResultChecking DEFAULT_WRITE_RESULT_CHECKING = WriteResultChecking.NONE;
|
||||
|
||||
private final MongoConverter mongoConverter;
|
||||
@@ -507,8 +507,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document fieldsObject = query.getFieldsObject();
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing query: {} sort: {} fields: {} in collection: {}", serializeToJsonSafely(queryObject),
|
||||
sortObject, fieldsObject, collectionName);
|
||||
LOGGER.debug(String.format("Executing query: %s sort: %s fields: %s in collection: %s",
|
||||
serializeToJsonSafely(queryObject), sortObject, fieldsObject, collectionName));
|
||||
}
|
||||
|
||||
this.executeQueryInternal(new FindCallback(queryObject, fieldsObject, null),
|
||||
@@ -700,8 +700,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
execute(collectionName, (CollectionCallback<Void>) collection -> {
|
||||
collection.drop();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Dropped collection [{}]",
|
||||
collection.getNamespace() != null ? collection.getNamespace().getCollectionName() : collectionName);
|
||||
LOGGER.debug(String.format("Dropped collection [%s]",
|
||||
collection.getNamespace() != null ? collection.getNamespace().getCollectionName() : collectionName));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
@@ -903,8 +903,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
MongoIterable<?> result = execute(collectionName, (collection) -> {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing findDistinct using query {} for field: {} in collection: {}",
|
||||
serializeToJsonSafely(mappedQuery), field, collectionName);
|
||||
LOGGER.debug(String.format("Executing findDistinct using query %s for field: %s in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), field, collectionName));
|
||||
}
|
||||
|
||||
QueryCursorPreparer preparer = new QueryCursorPreparer(query, entityClass);
|
||||
@@ -1126,7 +1126,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
protected long doCount(String collectionName, Document filter, CountOptions options) {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing count: {} in collection: {}", serializeToJsonSafely(filter), collectionName);
|
||||
LOGGER
|
||||
.debug(String.format("Executing count: %s in collection: %s", serializeToJsonSafely(filter), collectionName));
|
||||
}
|
||||
|
||||
return execute(collectionName,
|
||||
@@ -1453,7 +1454,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
protected Object insertDocument(String collectionName, Document document, Class<?> entityClass) {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Inserting Document containing fields: {} in collection: {}", document.keySet(), collectionName);
|
||||
LOGGER.debug(String.format("Inserting Document containing fields: %s in collection: %s", document.keySet(),
|
||||
collectionName));
|
||||
}
|
||||
|
||||
return execute(collectionName, collection -> {
|
||||
@@ -1478,7 +1480,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Inserting list of Documents containing {} items", documents.size());
|
||||
LOGGER.debug(String.format("Inserting list of Documents containing %s items", documents.size()));
|
||||
}
|
||||
|
||||
execute(collectionName, collection -> {
|
||||
@@ -1502,7 +1504,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
protected Object saveDocument(String collectionName, Document dbDoc, Class<?> entityClass) {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Saving Document containing fields: {}", dbDoc.keySet());
|
||||
LOGGER.debug(String.format("Saving Document containing fields: %s", dbDoc.keySet()));
|
||||
}
|
||||
|
||||
return execute(collectionName, collection -> {
|
||||
@@ -1607,8 +1609,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
if (query.isSorted() && LOGGER.isWarnEnabled()) {
|
||||
|
||||
LOGGER.warn("{} does not support sort ('{}'). Please use findAndModify() instead.",
|
||||
upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject()));
|
||||
LOGGER.warn(String.format("%s does not support sort ('%s'). Please use findAndModify() instead.",
|
||||
upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject())));
|
||||
}
|
||||
|
||||
MongoPersistentEntity<?> entity = entityClass == null ? null : getPersistentEntity(entityClass);
|
||||
@@ -1630,8 +1632,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
return execute(collectionName, collection -> {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Calling update using query: {} and update: {} in collection: {}",
|
||||
serializeToJsonSafely(queryObj), serializeToJsonSafely(pipeline), collectionName);
|
||||
LOGGER.debug(String.format("Calling update using query: %s and update: %s in collection: %s",
|
||||
serializeToJsonSafely(queryObj), serializeToJsonSafely(pipeline), collectionName));
|
||||
}
|
||||
|
||||
collection = writeConcernToUse != null ? collection.withWriteConcern(writeConcernToUse) : collection;
|
||||
@@ -1648,8 +1650,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
return execute(collectionName, collection -> {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Calling update using query: {} and update: {} in collection: {}", serializeToJsonSafely(queryObj),
|
||||
serializeToJsonSafely(updateObj), collectionName);
|
||||
LOGGER.debug(String.format("Calling update using query: %s and update: %s in collection: %s",
|
||||
serializeToJsonSafely(queryObj), serializeToJsonSafely(updateObj), collectionName));
|
||||
}
|
||||
|
||||
collection = writeConcernToUse != null ? collection.withWriteConcern(writeConcernToUse) : collection;
|
||||
@@ -1739,8 +1741,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document removeQuery = queryObject;
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Remove using query: {} in collection: {}.",
|
||||
new Object[] { serializeToJsonSafely(removeQuery), collectionName });
|
||||
LOGGER.debug(String.format("Remove using query: %s in collection: %s.", serializeToJsonSafely(removeQuery),
|
||||
collectionName));
|
||||
}
|
||||
|
||||
if (query.getLimit() > 0 || query.getSkip() > 0) {
|
||||
@@ -1954,13 +1956,13 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document commandObject = new Document("group", document);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing Group with Document [{}]", serializeToJsonSafely(commandObject));
|
||||
LOGGER.debug(String.format("Executing Group with Document [%s]", serializeToJsonSafely(commandObject)));
|
||||
}
|
||||
|
||||
Document commandResult = executeCommand(commandObject, this.readPreference);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Group command result = [{}]", commandResult);
|
||||
LOGGER.debug(String.format("Group command result = [%s]", commandResult));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -2132,7 +2134,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document command = aggregationUtil.createCommand(collectionName, aggregation, context);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing aggregation: {}", serializeToJsonSafely(command));
|
||||
LOGGER.debug(String.format("Executing aggregation: %s", serializeToJsonSafely(command)));
|
||||
}
|
||||
|
||||
Document commandResult = executeCommand(command);
|
||||
@@ -2143,7 +2145,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
List<Document> pipeline = aggregationUtil.createPipeline(aggregation, context);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing aggregation: {} in collection {}", serializeToJsonSafely(pipeline), collectionName);
|
||||
LOGGER.debug(
|
||||
String.format("Executing aggregation: %s in collection %s", serializeToJsonSafely(pipeline), collectionName));
|
||||
}
|
||||
|
||||
return execute(collectionName, collection -> {
|
||||
@@ -2209,7 +2212,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
List<Document> pipeline = aggregationDefinition.getAggregationPipeline();
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Streaming aggregation: {} in collection {}", serializeToJsonSafely(pipeline), collectionName);
|
||||
LOGGER.debug(
|
||||
String.format("Streaming aggregation: %s in collection %s", serializeToJsonSafely(pipeline), collectionName));
|
||||
}
|
||||
|
||||
ReadDocumentCallback<O> readCallback = new ReadDocumentCallback<>(mongoConverter, outputType, collectionName);
|
||||
@@ -2455,8 +2459,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
// TODO: Emit a collection created event
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Created collection [{}]",
|
||||
coll.getNamespace() != null ? coll.getNamespace().getCollectionName() : collectionName);
|
||||
LOGGER.debug(String.format("Created collection [%s]",
|
||||
coll.getNamespace() != null ? coll.getNamespace().getCollectionName() : collectionName));
|
||||
}
|
||||
return coll;
|
||||
});
|
||||
@@ -2499,8 +2503,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document mappedQuery = queryContext.getMappedQuery(entity);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("findOne using query: {} fields: {} for class: {} in collection: {}", serializeToJsonSafely(query),
|
||||
mappedFields, entityClass, collectionName);
|
||||
LOGGER.debug(String.format("findOne using query: %s fields: %s for class: %s in collection: %s",
|
||||
serializeToJsonSafely(query), mappedFields, entityClass, collectionName));
|
||||
}
|
||||
|
||||
return executeFindOneInternal(new FindOneCallback(mappedQuery, mappedFields, preparer),
|
||||
@@ -2551,8 +2555,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document mappedQuery = queryContext.getMappedQuery(entity);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("find using query: {} fields: {} for class: {} in collection: {}",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, entityClass, collectionName);
|
||||
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, entityClass, collectionName));
|
||||
}
|
||||
|
||||
return executeFindMultiInternal(new FindCallback(mappedQuery, mappedFields, null),
|
||||
@@ -2575,8 +2579,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document mappedQuery = queryContext.getMappedQuery(entity);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("find using query: {} fields: {} for class: {} in collection: {}",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName);
|
||||
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName));
|
||||
}
|
||||
|
||||
return executeFindMultiInternal(new FindCallback(mappedQuery, mappedFields, null), preparer,
|
||||
@@ -2678,8 +2682,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
EntityReader<? super T, Bson> readerToUse = this.mongoConverter;
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("findAndRemove using query: {} fields: {} sort: {} for class: {} in collection: {}",
|
||||
serializeToJsonSafely(query), fields, sort, entityClass, collectionName);
|
||||
LOGGER.debug(String.format("findAndRemove using query: %s fields: %s sort: %s for class: %s in collection: %s",
|
||||
serializeToJsonSafely(query), fields, sort, entityClass, collectionName));
|
||||
}
|
||||
|
||||
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
|
||||
@@ -2709,10 +2713,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
: updateContext.getMappedUpdate(entity);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"findAndModify using query: {} fields: {} sort: {} for class: {} and update: {} " + "in collection: {}",
|
||||
LOGGER.debug(String.format(
|
||||
"findAndModify using query: %s fields: %s sort: %s for class: %s and update: %s in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), fields, sort, entityClass, serializeToJsonSafely(mappedUpdate),
|
||||
collectionName);
|
||||
collectionName));
|
||||
}
|
||||
|
||||
return executeFindOneInternal(
|
||||
@@ -2742,10 +2746,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Document replacement, FindAndReplaceOptions options, Class<T> resultType) {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"findAndReplace using query: {} fields: {} sort: {} for class: {} and replacement: {} " + "in collection: {}",
|
||||
LOGGER.debug(String.format(
|
||||
"findAndReplace using query: %s fields: %s sort: %s for class: %s and replacement: %s " + "in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), serializeToJsonSafely(mappedFields), serializeToJsonSafely(mappedSort),
|
||||
entityType, serializeToJsonSafely(replacement), collectionName);
|
||||
entityType, serializeToJsonSafely(replacement), collectionName));
|
||||
}
|
||||
|
||||
return executeFindOneInternal(
|
||||
@@ -2937,9 +2941,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
||||
LOGGER.debug("findOne using query: {} fields: {} in db.collection: {}", serializeToJsonSafely(query),
|
||||
LOGGER.debug(String.format("findOne using query: %s fields: %s in db.collection: %s",
|
||||
serializeToJsonSafely(query),
|
||||
serializeToJsonSafely(fields.orElseGet(Document::new)),
|
||||
collection.getNamespace() != null ? collection.getNamespace().getFullName() : "n/a");
|
||||
collection.getNamespace() != null ? collection.getNamespace().getFullName() : "n/a"));
|
||||
}
|
||||
|
||||
if (fields.isPresent()) {
|
||||
|
||||
@@ -36,14 +36,14 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.BsonValue;
|
||||
import org.bson.Document;
|
||||
import org.bson.conversions.Bson;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -165,7 +165,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
|
||||
public static final DbRefResolver NO_OP_REF_RESOLVER = NoOpDbRefResolver.INSTANCE;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ReactiveMongoTemplate.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(ReactiveMongoTemplate.class);
|
||||
private static final WriteResultChecking DEFAULT_WRITE_RESULT_CHECKING = WriteResultChecking.NONE;
|
||||
|
||||
private final MongoConverter mongoConverter;
|
||||
@@ -829,7 +829,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
.projection(new Document("_id", 1));
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("exists: {} in collection: {}", serializeToJsonSafely(filter), collectionName);
|
||||
LOGGER.debug(String.format("exists: %s in collection: %s", serializeToJsonSafely(filter), collectionName));
|
||||
}
|
||||
|
||||
queryContext.applyCollation(entityClass, findPublisher::collation);
|
||||
@@ -911,8 +911,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
Flux<?> result = execute(collectionName, collection -> {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing findDistinct using query {} for field: {} in collection: {}",
|
||||
serializeToJsonSafely(mappedQuery), field, collectionName);
|
||||
LOGGER.debug(String.format("Executing findDistinct using query %s for field: %s in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), field, collectionName));
|
||||
}
|
||||
|
||||
FindPublisherPreparer preparer = new QueryFindPublisherPreparer(query, entityClass);
|
||||
@@ -988,8 +988,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
AggregationDefinition ctx = queryOperations.createAggregation(aggregation, inputType);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Streaming aggregation: {} in collection {}", serializeToJsonSafely(ctx.getAggregationPipeline()),
|
||||
collectionName);
|
||||
LOGGER.debug(String.format("Streaming aggregation: %s in collection %s",
|
||||
serializeToJsonSafely(ctx.getAggregationPipeline()), collectionName));
|
||||
}
|
||||
|
||||
ReadDocumentCallback<O> readCallback = new ReadDocumentCallback<>(mongoConverter, outputType, collectionName);
|
||||
@@ -1226,7 +1226,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
Document filter = countContext.getMappedQuery(entityClass, mappingContext::getPersistentEntity);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Executing count: {} in collection: {}", serializeToJsonSafely(filter), collectionName);
|
||||
LOGGER.debug(
|
||||
String.format("Executing count: %s in collection: %s", serializeToJsonSafely(filter), collectionName));
|
||||
}
|
||||
|
||||
return doCount(collectionName, filter, options);
|
||||
@@ -1556,7 +1557,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
protected Mono<Object> insertDocument(String collectionName, Document dbDoc, Class<?> entityClass) {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Inserting Document containing fields: " + dbDoc.keySet() + " in collection: " + collectionName);
|
||||
LOGGER.debug(String
|
||||
.format("Inserting Document containing fields: " + dbDoc.keySet() + " in collection: " + collectionName));
|
||||
}
|
||||
|
||||
Document document = new Document(dbDoc);
|
||||
@@ -1582,7 +1584,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Inserting list of Documents containing " + dbDocList.size() + " items");
|
||||
LOGGER.debug(String.format("Inserting list of Documents containing %d items", dbDocList.size()));
|
||||
}
|
||||
|
||||
List<Document> documents = new ArrayList<>();
|
||||
@@ -1620,7 +1622,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
protected Mono<Object> saveDocument(String collectionName, Document document, Class<?> entityClass) {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Saving Document containing fields: " + document.keySet());
|
||||
LOGGER.debug(String.format("Saving Document containing fields: %s", document.keySet()));
|
||||
}
|
||||
|
||||
return createMono(collectionName, collection -> {
|
||||
@@ -1747,8 +1749,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
|
||||
if (query.isSorted() && LOGGER.isWarnEnabled()) {
|
||||
|
||||
LOGGER.warn("{} does not support sort ('{}'). Please use findAndModify() instead.",
|
||||
upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject()));
|
||||
LOGGER.warn(String.format("%s does not support sort ('%s'). Please use findAndModify() instead.",
|
||||
upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject())));
|
||||
}
|
||||
|
||||
MongoPersistentEntity<?> entity = entityClass == null ? null : getPersistentEntity(entityClass);
|
||||
@@ -1959,8 +1961,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
MongoCollection<Document> collectionToUse = prepareCollection(collection, writeConcernToUse);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Remove using query: {} in collection: {}.",
|
||||
new Object[] { serializeToJsonSafely(removeQuery), collectionName });
|
||||
LOGGER.debug(String.format("Remove using query: %s in collection: %s.", serializeToJsonSafely(removeQuery),
|
||||
collectionName));
|
||||
}
|
||||
|
||||
if (query.getLimit() > 0 || query.getSkip() > 0) {
|
||||
@@ -2328,7 +2330,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
|
||||
// TODO: Emit a collection created event
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Created collection [{}]", collectionName);
|
||||
LOGGER.debug(String.format("Created collection [%s]", collectionName));
|
||||
}
|
||||
|
||||
}).then(getCollection(collectionName));
|
||||
@@ -2451,8 +2453,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
Document mappedQuery = queryContext.getMappedQuery(entity);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("find using query: {} fields: {} for class: {} in collection: {}",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName);
|
||||
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName));
|
||||
}
|
||||
|
||||
return executeFindMultiInternal(new FindCallback(mappedQuery, mappedFields), preparer,
|
||||
@@ -2611,11 +2613,11 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
return Mono.defer(() -> {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"findAndReplace using query: {} fields: {} sort: {} for class: {} and replacement: {} "
|
||||
+ "in collection: {}",
|
||||
LOGGER.debug(String.format(
|
||||
"findAndReplace using query: %s fields: %s sort: %s for class: %s and replacement: %s "
|
||||
+ "in collection: %s",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, mappedSort, entityType,
|
||||
serializeToJsonSafely(replacement), collectionName);
|
||||
serializeToJsonSafely(replacement), collectionName));
|
||||
}
|
||||
|
||||
return executeFindOneInternal(
|
||||
@@ -2898,8 +2900,9 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
||||
LOGGER.debug("findOne using query: {} fields: {} in db.collection: {}", serializeToJsonSafely(query),
|
||||
serializeToJsonSafely(fields.orElseGet(Document::new)), collection.getNamespace().getFullName());
|
||||
LOGGER.debug(
|
||||
String.format("findOne using query: %s fields: %s in db.collection: %s", serializeToJsonSafely(query),
|
||||
serializeToJsonSafely(fields.orElseGet(Document::new)), collection.getNamespace().getFullName()));
|
||||
}
|
||||
|
||||
FindPublisher<Document> publisher = preparer.initiateFind(collection, col -> col.find(query, Document.class));
|
||||
|
||||
@@ -22,9 +22,9 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
@@ -52,7 +52,7 @@ import com.mongodb.client.model.Filters;
|
||||
*/
|
||||
public class DefaultDbRefResolver extends DefaultReferenceResolver implements DbRefResolver, ReferenceResolver {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultDbRefResolver.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(DefaultDbRefResolver.class);
|
||||
|
||||
private final MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
@@ -130,10 +130,10 @@ public class DefaultDbRefResolver extends DefaultReferenceResolver implements Db
|
||||
MongoCollection<Document> mongoCollection = getCollection(databaseSource);
|
||||
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("Bulk fetching DBRefs {} from {}.{}.", ids,
|
||||
LOGGER.trace(String.format("Bulk fetching DBRefs %s from %s.%s.", ids,
|
||||
StringUtils.hasText(databaseSource.getDatabaseName()) ? databaseSource.getDatabaseName()
|
||||
: mongoCollection.getNamespace().getDatabaseName(),
|
||||
databaseSource.getCollectionName());
|
||||
databaseSource.getCollectionName()));
|
||||
}
|
||||
|
||||
List<Document> result = mongoCollection //
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.cglib.proxy.Callback;
|
||||
@@ -52,7 +52,7 @@ import com.mongodb.DBRef;
|
||||
*/
|
||||
class LazyLoadingProxyFactory {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LazyLoadingProxyFactory.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(LazyLoadingProxyFactory.class);
|
||||
|
||||
private final ObjenesisStd objenesis;
|
||||
|
||||
@@ -272,16 +272,16 @@ class LazyLoadingProxyFactory {
|
||||
if (resolved) {
|
||||
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("Accessing already resolved lazy loading property {}.{}",
|
||||
property.getOwner() != null ? property.getOwner().getName() : "unknown", property.getName());
|
||||
LOGGER.trace(String.format("Accessing already resolved lazy loading property %s.%s",
|
||||
property.getOwner() != null ? property.getOwner().getName() : "unknown", property.getName()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("Resolving lazy loading property {}.{}",
|
||||
property.getOwner() != null ? property.getOwner().getName() : "unknown", property.getName());
|
||||
LOGGER.trace(String.format("Resolving lazy loading property %s.%s",
|
||||
property.getOwner() != null ? property.getOwner().getName() : "unknown", property.getName()));
|
||||
}
|
||||
|
||||
return callback.resolve(property);
|
||||
|
||||
@@ -29,14 +29,15 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.bson.codecs.Codec;
|
||||
import org.bson.codecs.DecoderContext;
|
||||
import org.bson.conversions.Bson;
|
||||
import org.bson.json.JsonReader;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
@@ -110,7 +111,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
||||
|
||||
public static final ClassTypeInformation<Bson> BSON = ClassTypeInformation.from(Bson.class);
|
||||
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(MappingMongoConverter.class);
|
||||
protected static final Log LOGGER = LogFactory.getLog(MappingMongoConverter.class);
|
||||
|
||||
protected final MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext;
|
||||
protected final QueryMapper idMapper;
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.core.convert;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseUtils;
|
||||
import org.springframework.data.mongodb.core.convert.ReferenceResolver.ReferenceCollection;
|
||||
@@ -35,7 +36,7 @@ import com.mongodb.client.MongoCollection;
|
||||
*/
|
||||
public class MongoDatabaseFactoryReferenceLoader implements ReferenceLoader {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MongoDatabaseFactoryReferenceLoader.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(MongoDatabaseFactoryReferenceLoader.class);
|
||||
|
||||
private final MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
@@ -55,10 +56,10 @@ public class MongoDatabaseFactoryReferenceLoader implements ReferenceLoader {
|
||||
MongoCollection<Document> collection = getCollection(context);
|
||||
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("Bulk fetching {} from {}.{}.", referenceQuery,
|
||||
LOGGER.trace(String.format("Bulk fetching %s from %s.%s.", referenceQuery,
|
||||
StringUtils.hasText(context.getDatabase()) ? context.getDatabase()
|
||||
: collection.getNamespace().getDatabaseName(),
|
||||
context.getCollection());
|
||||
context.getCollection()));
|
||||
}
|
||||
|
||||
return referenceQuery.apply(collection);
|
||||
|
||||
@@ -21,12 +21,13 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.BsonValue;
|
||||
import org.bson.Document;
|
||||
import org.bson.conversions.Bson;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
@@ -74,7 +75,7 @@ import com.mongodb.DBRef;
|
||||
*/
|
||||
public class QueryMapper {
|
||||
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(QueryMapper.class);
|
||||
protected static final Log LOGGER = LogFactory.getLog(QueryMapper.class);
|
||||
|
||||
private static final List<String> DEFAULT_ID_NAMES = Arrays.asList("id", "_id");
|
||||
private static final Document META_TEXT_SCORE = new Document("$meta", "textScore");
|
||||
@@ -1224,9 +1225,9 @@ public class QueryMapper {
|
||||
|
||||
String types = StringUtils.collectionToDelimitedString(
|
||||
path.stream().map(it -> it.getType().getSimpleName()).collect(Collectors.toList()), " -> ");
|
||||
QueryMapper.LOGGER.info(
|
||||
"Could not map '{}'. Maybe a fragment in '{}' is considered a simple type. Mapper continues with {}.",
|
||||
path, types, pathExpression);
|
||||
QueryMapper.LOGGER.info(String.format(
|
||||
"Could not map '%s'. Maybe a fragment in '%s' is considered a simple type. Mapper continues with %s.",
|
||||
path, types, pathExpression));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
@@ -53,7 +54,7 @@ import com.mongodb.MongoException;
|
||||
*/
|
||||
public class MongoPersistentEntityIndexCreator implements ApplicationListener<MappingContextEvent<?, ?>> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MongoPersistentEntityIndexCreator.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(MongoPersistentEntityIndexCreator.class);
|
||||
|
||||
private final Map<Class<?>, Boolean> classesSeen = new ConcurrentHashMap<Class<?>, Boolean>();
|
||||
private final IndexOperationsProvider indexOperationsProvider;
|
||||
|
||||
@@ -27,8 +27,9 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mapping.Association;
|
||||
@@ -77,7 +78,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class MongoPersistentEntityIndexResolver implements IndexResolver {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MongoPersistentEntityIndexResolver.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(MongoPersistentEntityIndexResolver.class);
|
||||
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
private final MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext;
|
||||
|
||||
@@ -23,8 +23,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mongodb.UncategorizedMongoDbException;
|
||||
@@ -47,7 +48,7 @@ import com.mongodb.MongoException;
|
||||
*/
|
||||
public class ReactiveMongoPersistentEntityIndexCreator {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ReactiveMongoPersistentEntityIndexCreator.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(ReactiveMongoPersistentEntityIndexCreator.class);
|
||||
|
||||
private final Map<Class<?>, Boolean> classesSeen = new ConcurrentHashMap<Class<?>, Boolean>();
|
||||
private final MongoMappingContext mappingContext;
|
||||
|
||||
@@ -23,9 +23,10 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.data.mapping.Association;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
|
||||
@@ -54,7 +55,7 @@ import org.springframework.util.StringUtils;
|
||||
public class BasicMongoPersistentProperty extends AnnotationBasedPersistentProperty<MongoPersistentProperty>
|
||||
implements MongoPersistentProperty {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BasicMongoPersistentProperty.class);
|
||||
private static final Log LOG = LogFactory.getLog(BasicMongoPersistentProperty.class);
|
||||
|
||||
public static final String ID_FIELD_NAME = "_id";
|
||||
private static final String LANGUAGE_FIELD_NAME = "language";
|
||||
@@ -92,9 +93,9 @@ public class BasicMongoPersistentProperty extends AnnotationBasedPersistentPrope
|
||||
|
||||
String annotatedName = getAnnotatedFieldName();
|
||||
if (!ID_FIELD_NAME.equals(annotatedName)) {
|
||||
LOG.warn(
|
||||
"Customizing field name for id property '{}.{}' is not allowed! Custom name ('{}') will not be considered!",
|
||||
owner.getName(), getName(), annotatedName);
|
||||
LOG.warn(String.format(
|
||||
"Customizing field name for id property '%s.%s' is not allowed! Custom name ('%s') will not be considered!",
|
||||
owner.getName(), getName(), annotatedName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +311,7 @@ public class BasicMongoPersistentProperty extends AnnotationBasedPersistentPrope
|
||||
|
||||
/**
|
||||
* Obtain the {@link EvaluationContext} for a specific root object.
|
||||
*
|
||||
*
|
||||
* @param rootObject can be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
* @since 3.3
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.core.mapping.event;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
|
||||
@@ -30,7 +31,7 @@ import org.springframework.core.GenericTypeResolver;
|
||||
*/
|
||||
public abstract class AbstractMongoEventListener<E> implements ApplicationListener<MongoMappingEvent<?>> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractMongoEventListener.class);
|
||||
private static final Log LOG = LogFactory.getLog(AbstractMongoEventListener.class);
|
||||
private final Class<?> domainClass;
|
||||
|
||||
/**
|
||||
@@ -103,7 +104,7 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen
|
||||
public void onBeforeConvert(BeforeConvertEvent<E> event) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("onBeforeConvert({})", event.getSource());
|
||||
LOG.debug(String.format("onBeforeConvert(%s)", event.getSource()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen
|
||||
public void onBeforeSave(BeforeSaveEvent<E> event) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("onBeforeSave({}, {})", event.getSource(), event.getDocument());
|
||||
LOG.debug(String.format("onBeforeSave(%s, %s)", event.getSource(), event.getDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen
|
||||
public void onAfterSave(AfterSaveEvent<E> event) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("onAfterSave({}, {})", event.getSource(), event.getDocument());
|
||||
LOG.debug(String.format("onAfterSave(%s, %s)", event.getSource(), event.getDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen
|
||||
public void onAfterLoad(AfterLoadEvent<E> event) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("onAfterLoad({})", event.getDocument());
|
||||
LOG.debug(String.format("onAfterLoad(%s)", event.getDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen
|
||||
public void onAfterConvert(AfterConvertEvent<E> event) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("onAfterConvert({}, {})", event.getDocument(), event.getSource());
|
||||
LOG.debug(String.format("onAfterConvert(%s, %s)", event.getDocument(), event.getSource()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen
|
||||
public void onAfterDelete(AfterDeleteEvent<E> event) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("onAfterDelete({})", event.getDocument());
|
||||
LOG.debug(String.format("onAfterDelete(%s)", event.getDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen
|
||||
public void onBeforeDelete(BeforeDeleteEvent<E> event) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("onBeforeDelete({})", event.getDocument());
|
||||
LOG.debug(String.format("onBeforeDelete(%s)", event.getDocument()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ package org.springframework.data.mongodb.core.mapping.event;
|
||||
|
||||
import static org.springframework.data.mongodb.core.query.SerializationUtils.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
|
||||
/**
|
||||
@@ -31,7 +32,7 @@ import org.springframework.context.ApplicationListener;
|
||||
*/
|
||||
public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoggingEventListener.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(LoggingEventListener.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -39,7 +40,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
*/
|
||||
@Override
|
||||
public void onBeforeConvert(BeforeConvertEvent<Object> event) {
|
||||
LOGGER.info("onBeforeConvert: {}", event.getSource());
|
||||
LOGGER.info(String.format("onBeforeConvert: %s", event.getSource()));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -48,7 +49,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
*/
|
||||
@Override
|
||||
public void onBeforeSave(BeforeSaveEvent<Object> event) {
|
||||
LOGGER.info("onBeforeSave: {}, {}", event.getSource(), serializeToJsonSafely(event.getDocument()));
|
||||
LOGGER.info(String.format("onBeforeSave: %s, %s", event.getSource(), serializeToJsonSafely(event.getDocument())));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -57,7 +58,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
*/
|
||||
@Override
|
||||
public void onAfterSave(AfterSaveEvent<Object> event) {
|
||||
LOGGER.info("onAfterSave: {}, {}", event.getSource(), serializeToJsonSafely(event.getDocument()));
|
||||
LOGGER.info(String.format("onAfterSave: %s, %s", event.getSource(), serializeToJsonSafely(event.getDocument())));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -66,7 +67,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
*/
|
||||
@Override
|
||||
public void onAfterLoad(AfterLoadEvent<Object> event) {
|
||||
LOGGER.info("onAfterLoad: {}", serializeToJsonSafely(event.getDocument()));
|
||||
LOGGER.info(String.format("onAfterLoad: %s", serializeToJsonSafely(event.getDocument())));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -75,7 +76,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
*/
|
||||
@Override
|
||||
public void onAfterConvert(AfterConvertEvent<Object> event) {
|
||||
LOGGER.info("onAfterConvert: {}, {}", serializeToJsonSafely(event.getDocument()), event.getSource());
|
||||
LOGGER.info(String.format("onAfterConvert: %s, %s", serializeToJsonSafely(event.getDocument()), event.getSource()));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -84,7 +85,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
*/
|
||||
@Override
|
||||
public void onAfterDelete(AfterDeleteEvent<Object> event) {
|
||||
LOGGER.info("onAfterDelete: {}", serializeToJsonSafely(event.getDocument()));
|
||||
LOGGER.info(String.format("onAfterDelete: %s", serializeToJsonSafely(event.getDocument())));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -93,6 +94,6 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
|
||||
*/
|
||||
@Override
|
||||
public void onBeforeDelete(BeforeDeleteEvent<Object> event) {
|
||||
LOGGER.info("onBeforeDelete: {}", serializeToJsonSafely(event.getDocument()));
|
||||
LOGGER.info(String.format("onBeforeDelete: %s", serializeToJsonSafely(event.getDocument())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@ import java.util.Set;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -34,7 +35,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ValidatingMongoEventListener extends AbstractMongoEventListener<Object> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ValidatingMongoEventListener.class);
|
||||
private static final Log LOG = LogFactory.getLog(ValidatingMongoEventListener.class);
|
||||
|
||||
private final Validator validator;
|
||||
|
||||
@@ -57,12 +58,16 @@ public class ValidatingMongoEventListener extends AbstractMongoEventListener<Obj
|
||||
@Override
|
||||
public void onBeforeSave(BeforeSaveEvent<Object> event) {
|
||||
|
||||
LOG.debug("Validating object: {}", event.getSource());
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Validating object: {}", event.getSource()));
|
||||
}
|
||||
Set violations = validator.validate(event.getSource());
|
||||
|
||||
if (!violations.isEmpty()) {
|
||||
|
||||
LOG.info("During object: {} validation violations found: {}", event.getSource(), violations);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.info(String.format("During object: {} validation violations found: {}", event.getSource(), violations));
|
||||
}
|
||||
throw new ConstraintViolationException(violations);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,9 @@ import javax.enterprise.inject.spi.Bean;
|
||||
import javax.enterprise.inject.spi.BeanManager;
|
||||
import javax.enterprise.inject.spi.ProcessBean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.repository.cdi.CdiRepositoryBean;
|
||||
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
|
||||
@@ -45,7 +46,7 @@ import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
|
||||
*/
|
||||
public class MongoRepositoryExtension extends CdiRepositoryExtensionSupport {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MongoRepositoryExtension.class);
|
||||
private static final Log LOG = LogFactory.getLog(MongoRepositoryExtension.class);
|
||||
|
||||
private final Map<Set<Annotation>, Bean<MongoOperations>> mongoOperations = new HashMap<Set<Annotation>, Bean<MongoOperations>>();
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.domain.Range.Bound;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -65,7 +66,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MongoQueryCreator.class);
|
||||
private static final Log LOG = LogFactory.getLog(MongoQueryCreator.class);
|
||||
|
||||
private final MongoParameterAccessor accessor;
|
||||
private final MappingContext<?, MongoPersistentProperty> context;
|
||||
|
||||
@@ -17,9 +17,10 @@ package org.springframework.data.mongodb.repository.query;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
|
||||
import org.springframework.data.mongodb.core.query.BasicQuery;
|
||||
@@ -43,7 +44,7 @@ import org.springframework.util.Assert;
|
||||
public class ReactiveStringBasedMongoQuery extends AbstractReactiveMongoQuery {
|
||||
|
||||
private static final String COUNT_EXISTS_AND_DELETE = "Manually defined query for %s cannot be a count and exists or delete query at the same time!";
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ReactiveStringBasedMongoQuery.class);
|
||||
private static final Log LOG = LogFactory.getLog(ReactiveStringBasedMongoQuery.class);
|
||||
|
||||
private final String query;
|
||||
private final String fieldSpec;
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.repository.query;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.data.mapping.model.SpELExpressionEvaluator;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.query.BasicQuery;
|
||||
@@ -41,7 +42,7 @@ import org.springframework.util.Assert;
|
||||
public class StringBasedMongoQuery extends AbstractMongoQuery {
|
||||
|
||||
private static final String COUNT_EXISTS_AND_DELETE = "Manually defined query for %s cannot be a count and exists or delete query at the same time!";
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StringBasedMongoQuery.class);
|
||||
private static final Log LOG = LogFactory.getLog(StringBasedMongoQuery.class);
|
||||
|
||||
private final String query;
|
||||
private final String fieldSpec;
|
||||
|
||||
@@ -20,8 +20,9 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
@@ -54,7 +55,7 @@ import com.mongodb.MongoException;
|
||||
class IndexEnsuringQueryCreationListener implements QueryCreationListener<PartTreeMongoQuery> {
|
||||
|
||||
private static final Set<Type> GEOSPATIAL_TYPES = new HashSet<Type>(Arrays.asList(Type.NEAR, Type.WITHIN));
|
||||
private static final Logger LOG = LoggerFactory.getLogger(IndexEnsuringQueryCreationListener.class);
|
||||
private static final Log LOG = LogFactory.getLog(IndexEnsuringQueryCreationListener.class);
|
||||
|
||||
private final IndexOperationsProvider indexOperationsProvider;
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ package org.springframework.data.mongodb.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
@@ -29,7 +30,7 @@ import org.springframework.context.support.AbstractApplicationContext;
|
||||
*/
|
||||
public class PersonExample {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PersonExample.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(PersonExample.class);
|
||||
|
||||
@Autowired private MongoOperations mongoOps;
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.assertj.core.data.Offset;
|
||||
import org.bson.Document;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -42,8 +44,6 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -94,7 +94,7 @@ import com.mongodb.client.model.WriteModel;
|
||||
public class AggregationTests {
|
||||
|
||||
private static final String INPUT_COLLECTION = "aggregation_test_collection";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AggregationTests.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(AggregationTests.class);
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class LoggingEventListenerTests {
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
|
||||
appender = new ListAppender<ILoggingEvent>();
|
||||
appender = new ListAppender<>();
|
||||
|
||||
// set log level for LoggingEventListener to "info" and set up an appender capturing events.
|
||||
logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(LoggingEventListener.class);
|
||||
|
||||
@@ -23,12 +23,13 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -48,7 +49,7 @@ import com.mongodb.client.MongoDatabase;
|
||||
*/
|
||||
public class CleanMongoDB implements TestRule {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CleanMongoDB.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(CleanMongoDB.class);
|
||||
|
||||
/**
|
||||
* Defines contents of MongoDB.
|
||||
@@ -288,7 +289,7 @@ public class CleanMongoDB implements TestRule {
|
||||
}
|
||||
|
||||
client.getDatabase(dbName).drop();
|
||||
LOGGER.debug("Dropping DB '{}'. ", dbName);
|
||||
LOGGER.debug(String.format("Dropping DB '%s'. ", dbName));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -305,10 +306,11 @@ public class CleanMongoDB implements TestRule {
|
||||
|
||||
if (types.contains(Struct.COLLECTION)) {
|
||||
collection.drop();
|
||||
LOGGER.debug("Dropping collection '{}' for DB '{}'. ", collectionName, db.getName());
|
||||
LOGGER.debug(String.format("Dropping collection '%s' for DB '%s'. ", collectionName, db.getName()));
|
||||
} else if (types.contains(Struct.INDEX)) {
|
||||
collection.dropIndexes();
|
||||
LOGGER.debug("Dropping indexes in collection '{}' for DB '{}'. ", collectionName, db.getName());
|
||||
LOGGER.debug(
|
||||
String.format("Dropping indexes in collection '%s' for DB '%s'. ", collectionName, db.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import static org.junit.platform.commons.util.ReflectionUtils.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.Extension;
|
||||
@@ -33,8 +35,7 @@ import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
import org.junit.platform.commons.util.ExceptionUtils;
|
||||
import org.junit.platform.commons.util.ReflectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import com.mongodb.client.MongoClient;
|
||||
@@ -48,7 +49,7 @@ import com.mongodb.client.MongoClient;
|
||||
*/
|
||||
public class MongoClientExtension implements Extension, BeforeAllCallback, AfterAllCallback, ParameterResolver {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MongoClientExtension.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(MongoClientExtension.class);
|
||||
|
||||
private static final Namespace NAMESPACE = MongoExtensions.Client.NAMESPACE;
|
||||
|
||||
@@ -111,13 +112,13 @@ public class MongoClientExtension implements Extension, BeforeAllCallback, After
|
||||
|
||||
private ReactiveClientHolder reactiveClient(boolean replSet) {
|
||||
|
||||
LOGGER.debug("Creating new reactive {}client.", replSet ? "replica set " : "");
|
||||
LOGGER.debug(String.format("Creating new reactive %sclient.", replSet ? "replica set " : ""));
|
||||
return new ReactiveClientHolder(replSet ? MongoTestUtils.reactiveReplSetClient() : MongoTestUtils.reactiveClient());
|
||||
}
|
||||
|
||||
private SyncClientHolder syncClient(boolean replSet) {
|
||||
|
||||
LOGGER.debug("Creating new sync {}client.", replSet ? "replica set " : "");
|
||||
LOGGER.debug(String.format("Creating new sync %sclient.", replSet ? "replica set " : ""));
|
||||
return new SyncClientHolder(replSet ? MongoTestUtils.replSetClient() : MongoTestUtils.client());
|
||||
}
|
||||
|
||||
@@ -135,9 +136,9 @@ public class MongoClientExtension implements Extension, BeforeAllCallback, After
|
||||
private void assertSupportedType(String target, Class<?> type) {
|
||||
|
||||
if (type != com.mongodb.client.MongoClient.class && type != com.mongodb.reactivestreams.client.MongoClient.class) {
|
||||
throw new ExtensionConfigurationException("Can only resolve @MongoClient " + target + " of type "
|
||||
+ com.mongodb.client.MongoClient.class.getName() + " or "
|
||||
+ com.mongodb.reactivestreams.client.MongoClient.class.getName() + " but was: " + type.getName());
|
||||
throw new ExtensionConfigurationException(String.format(
|
||||
"Can only resolve @MongoClient %s of type %s or %s but was: %s", target, MongoClient.class.getName(),
|
||||
com.mongodb.reactivestreams.client.MongoClient.class.getName(), type.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user