Migrate off SLF4J to Spring JCL.

Closes #1194
This commit is contained in:
Mark Paluch
2021-11-16 11:12:36 +01:00
parent f20b81e9cc
commit 880787ff88
17 changed files with 154 additions and 144 deletions

View File

@@ -27,8 +27,8 @@ import java.util.function.IntFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
@@ -82,6 +82,8 @@ public class CqlSessionFactoryBean
private static final CassandraExceptionTranslator EXCEPTION_TRANSLATOR = new CassandraExceptionTranslator();
protected final Log log = LogFactory.getLog(getClass());
private int port = DEFAULT_PORT;
private @Nullable CassandraConverter converter;
@@ -101,8 +103,6 @@ public class CqlSessionFactoryBean
private List<String> startupScripts = Collections.emptyList();
private List<String> shutdownScripts = Collections.emptyList();
protected final Logger logger = LoggerFactory.getLogger(getClass());
private Set<KeyspaceActionSpecification> keyspaceSpecifications = new HashSet<>();
private SchemaAction schemaAction = SchemaAction.NONE;
@@ -683,7 +683,9 @@ public class CqlSessionFactoryBean
private void executeCql(Stream<String> cql, CqlSession session) {
cql.forEach(query -> {
this.logger.info("Executing CQL [{}]", query);
if (this.log.isInfoEnabled()) {
this.log.info(String.format("Executing CQL [%s]", query));
}
session.execute(query);
});
}

View File

@@ -22,26 +22,8 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.api.querybuilder.delete.Delete;
import com.datastax.oss.driver.api.querybuilder.insert.Insert;
import com.datastax.oss.driver.api.querybuilder.insert.RegularInsert;
import com.datastax.oss.driver.api.querybuilder.select.Select;
import com.datastax.oss.driver.api.querybuilder.truncate.Truncate;
import com.datastax.oss.driver.api.querybuilder.update.Update;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
@@ -81,6 +63,25 @@ import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.util.Assert;
import org.springframework.util.concurrent.ListenableFuture;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.api.querybuilder.delete.Delete;
import com.datastax.oss.driver.api.querybuilder.insert.Insert;
import com.datastax.oss.driver.api.querybuilder.insert.RegularInsert;
import com.datastax.oss.driver.api.querybuilder.select.Select;
import com.datastax.oss.driver.api.querybuilder.truncate.Truncate;
import com.datastax.oss.driver.api.querybuilder.update.Update;
/**
* Primary implementation of {@link AsyncCassandraOperations}. It simplifies the use of asynchronous Cassandra usage and
* helps to avoid common errors. It executes core Cassandra workflow. This class executes CQL queries or updates,
@@ -108,7 +109,7 @@ import org.springframework.util.concurrent.ListenableFuture;
public class AsyncCassandraTemplate
implements AsyncCassandraOperations, ApplicationEventPublisherAware, ApplicationContextAware {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Log log = LogFactory.getLog(getClass());
private final AsyncCqlOperations cqlOperations;
@@ -874,7 +875,7 @@ public class AsyncCassandraTemplate
private <T> ListenableFuture<List<T>> doQuery(Statement<?> statement, RowMapper<T> rowMapper) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getAsyncCqlOperations().query(statementHandler, statementHandler, rowMapper);
@@ -885,7 +886,7 @@ public class AsyncCassandraTemplate
private ListenableFuture<Void> doQuery(Statement<?> statement, RowCallbackHandler callbackHandler) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getAsyncCqlOperations().query(statementHandler, statementHandler, callbackHandler);
@@ -900,7 +901,7 @@ public class AsyncCassandraTemplate
private <T> ListenableFuture<T> doExecute(Statement<?> statement, Function<AsyncResultSet, T> mappingFunction) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getAsyncCqlOperations().query(statementHandler, statementHandler,

View File

@@ -20,26 +20,8 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Stream;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.cql.BatchType;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.api.querybuilder.delete.Delete;
import com.datastax.oss.driver.api.querybuilder.insert.Insert;
import com.datastax.oss.driver.api.querybuilder.insert.RegularInsert;
import com.datastax.oss.driver.api.querybuilder.select.Select;
import com.datastax.oss.driver.api.querybuilder.truncate.Truncate;
import com.datastax.oss.driver.api.querybuilder.update.Update;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
@@ -78,6 +60,25 @@ import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.cql.BatchType;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.api.querybuilder.delete.Delete;
import com.datastax.oss.driver.api.querybuilder.insert.Insert;
import com.datastax.oss.driver.api.querybuilder.insert.RegularInsert;
import com.datastax.oss.driver.api.querybuilder.select.Select;
import com.datastax.oss.driver.api.querybuilder.truncate.Truncate;
import com.datastax.oss.driver.api.querybuilder.update.Update;
/**
* Primary implementation of {@link CassandraOperations}. It simplifies the use of Cassandra usage and helps to avoid
* common errors. It executes core Cassandra workflow. This class executes CQL queries or updates, initiating iteration
@@ -106,7 +107,7 @@ import org.springframework.util.Assert;
*/
public class CassandraTemplate implements CassandraOperations, ApplicationEventPublisherAware, ApplicationContextAware {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Log log = LogFactory.getLog(getClass());
private final CqlOperations cqlOperations;
@@ -919,7 +920,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
private <T> List<T> doQuery(Statement<?> statement, RowMapper<T> rowMapper) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getCqlOperations().query(statementHandler, statementHandler, rowMapper);
@@ -934,7 +935,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
private <T> Stream<T> doQueryForStream(Statement<?> statement, RowMapper<T> rowMapper) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getCqlOperations().queryForStream(statementHandler, statementHandler, rowMapper);
@@ -953,7 +954,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
private <T> T doExecute(Statement<?> statement, Function<ResultSet, T> mappingFunction) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getCqlOperations().query(statementHandler, statementHandler, mappingFunction::apply);

View File

@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.core;
import java.util.Map;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.springframework.data.cassandra.core.cql.QueryExtractorDelegate;
import org.springframework.util.StringUtils;
@@ -92,7 +92,7 @@ class PreparedStatementDelegate {
* @param logger
* @return
*/
static boolean canPrepare(boolean usePreparedStatements, Statement<?> statement, Logger logger) {
static boolean canPrepare(boolean usePreparedStatements, Statement<?> statement, Log logger) {
if (usePreparedStatements) {

View File

@@ -15,33 +15,17 @@
*/
package org.springframework.data.cassandra.core;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.SynchronousSink;
import java.util.Collections;
import java.util.function.BiConsumer;
import java.util.function.Function;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.context.DriverContext;
import com.datastax.oss.driver.api.core.cql.BatchType;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.api.querybuilder.delete.Delete;
import com.datastax.oss.driver.api.querybuilder.insert.Insert;
import com.datastax.oss.driver.api.querybuilder.insert.RegularInsert;
import com.datastax.oss.driver.api.querybuilder.select.Select;
import com.datastax.oss.driver.api.querybuilder.truncate.Truncate;
import com.datastax.oss.driver.api.querybuilder.update.Update;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.SynchronousSink;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
@@ -82,6 +66,24 @@ import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.context.DriverContext;
import com.datastax.oss.driver.api.core.cql.BatchType;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.api.querybuilder.delete.Delete;
import com.datastax.oss.driver.api.querybuilder.insert.Insert;
import com.datastax.oss.driver.api.querybuilder.insert.RegularInsert;
import com.datastax.oss.driver.api.querybuilder.select.Select;
import com.datastax.oss.driver.api.querybuilder.truncate.Truncate;
import com.datastax.oss.driver.api.querybuilder.update.Update;
/**
* Primary implementation of {@link ReactiveCassandraOperations}. It simplifies the use of Reactive Cassandra usage and
* helps to avoid common errors. It executes core Cassandra workflow. This class executes CQL queries or updates,
@@ -111,7 +113,7 @@ import org.springframework.util.Assert;
public class ReactiveCassandraTemplate
implements ReactiveCassandraOperations, ApplicationEventPublisherAware, ApplicationContextAware {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Log log = LogFactory.getLog(getClass());
private final ReactiveCqlOperations cqlOperations;
@@ -886,7 +888,7 @@ public class ReactiveCassandraTemplate
private <T> Flux<T> doQuery(Statement<?> statement, RowMapper<T> rowMapper) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getReactiveCqlOperations().query(statementHandler, statementHandler, rowMapper);
@@ -897,7 +899,7 @@ public class ReactiveCassandraTemplate
private <T> Mono<T> doExecute(Statement<?> statement, Function<ReactiveResultSet, T> mappingFunction) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getReactiveCqlOperations()
@@ -910,7 +912,7 @@ public class ReactiveCassandraTemplate
private <T> Mono<T> doExecuteAndFlatMap(Statement<?> statement,
Function<ReactiveResultSet, Mono<T>> mappingFunction) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, logger)) {
if (PreparedStatementDelegate.canPrepare(isUsePreparedStatements(), statement, log)) {
PreparedStatementHandler statementHandler = new PreparedStatementHandler(statement);
return getReactiveCqlOperations().query(statementHandler, statementHandler, mappingFunction::apply).next();

View File

@@ -23,8 +23,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
@@ -81,7 +81,7 @@ import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry;
public class MappingCassandraConverter extends AbstractCassandraConverter
implements ApplicationContextAware, BeanClassLoaderAware {
private final Logger log = LoggerFactory.getLogger(getClass());
private final Log log = LogFactory.getLog(getClass());
private final CassandraMappingContext mappingContext;
@@ -518,7 +518,8 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
Object value = getWriteValue(property, accessor);
if (log.isDebugEnabled()) {
log.debug("doWithProperties Property.type {}, Property.value {}", property.getType().getName(), value);
log.debug(
String.format("doWithProperties Property.type %s, Property.value %s", property.getType().getName(), value));
}
if (!property.isWritable()) {
@@ -528,14 +529,14 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
if (value != null && property.isEmbedded()) {
if (log.isDebugEnabled()) {
log.debug("Mapping embedded property [{}] - [{}]", property.getRequiredColumnName(), value);
log.debug(String.format("Mapping embedded property [%s] - [%s]", property.getRequiredColumnName(), value));
}
write(value, sink, embeddedEntityOperations.getEntity(property));
} else {
if (log.isDebugEnabled()) {
log.debug("Adding map.entry [{}] - [{}]", property.getRequiredColumnName(), value);
log.debug(String.format("Adding map.entry [%s] - [%s]", property.getRequiredColumnName(), value));
}
sink.put(property.getRequiredColumnName(), value);
@@ -644,11 +645,12 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
Object value = getWriteValue(property, propertyAccessor);
if (log.isDebugEnabled()) {
log.debug("writeTupleValue Property.type {}, Property.value {}", property.getType().getName(), value);
log.debug(
String.format("writeTupleValue Property.type %s, Property.value %s", property.getType().getName(), value));
}
if (log.isDebugEnabled()) {
log.debug("Adding tuple value [{}] - [{}]", property.getOrdinal(), value);
log.debug(String.format("Adding tuple value [%s] - [%s]", property.getOrdinal(), value));
}
TypeCodec<Object> typeCodec = getCodec(property);
@@ -670,18 +672,18 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
Object value = getWriteValue(property, propertyAccessor);
if (log.isDebugEnabled()) {
log.debug("writeUDTValueWhereFromObject Property.type {}, Property.value {}", property.getType().getName(),
value);
log.debug(String.format("writeUDTValueWhereFromObject Property.type %s, Property.value %s",
property.getType().getName(), value));
}
if (log.isDebugEnabled()) {
log.debug("Adding udt.value [{}] - [{}]", property.getRequiredColumnName(), value);
log.debug(String.format("Adding udt.value [%s] - [%s]", property.getRequiredColumnName(), value));
}
if (property.isEmbedded()) {
if (log.isDebugEnabled()) {
log.debug("Mapping embedded property [{}] - [{}]", property.getRequiredColumnName(), value);
log.debug(String.format("Mapping embedded property [%s] - [%s]", property.getRequiredColumnName(), value));
}
if (value == null) {

View File

@@ -18,8 +18,8 @@ package org.springframework.data.cassandra.core.cql;
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.util.Assert;
@@ -45,7 +45,7 @@ public class CachedPreparedStatementCreator implements PreparedStatementCreator
private static final Map<CqlSession, Map<String, PreparedStatement>> CACHE = new ConcurrentHashMap<>();
protected final Logger log = LoggerFactory.getLogger(getClass());
protected final Log log = LogFactory.getLog(getClass());
private final String cql;
@@ -79,7 +79,7 @@ public class CachedPreparedStatementCreator implements PreparedStatementCreator
CqlIdentifier keyspace = session.getKeyspace().orElse(CqlIdentifier.fromCql("unknown"));
String cacheKey = keyspace.asInternal().concat("|").concat(this.cql);
log.debug("Cacheable PreparedStatement in Keyspace {}", keyspace.asCql(true));
log.debug(String.format("Cacheable PreparedStatement in Keyspace %s", keyspace.asCql(true)));
Map<String, PreparedStatement> sessionCache = getOrCreateSessionLocalCache(session);

View File

@@ -17,8 +17,8 @@ package org.springframework.data.cassandra.core.cql;
import java.util.Map;
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.InitializingBean;
import org.springframework.dao.DataAccessException;
@@ -52,7 +52,7 @@ import com.datastax.oss.driver.api.core.retry.RetryPolicy;
public class CassandraAccessor implements InitializingBean {
/** Logger available to subclasses */
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final Log logger = LogFactory.getLog(getClass());
private CqlExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();

View File

@@ -15,9 +15,8 @@
*/
package org.springframework.data.cassandra.core.cql;
import com.datastax.oss.driver.api.core.DriverException;
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.InitializingBean;
import org.springframework.dao.DataAccessException;
@@ -26,6 +25,8 @@ import org.springframework.data.cassandra.ReactiveSessionFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.DriverException;
/**
* Base class for {@link ReactiveCqlTemplate} and other CQL-accessing DAO helpers, defining common properties such as
* {@link ReactiveSessionFactory} and exception translator.
@@ -41,7 +42,7 @@ import org.springframework.util.Assert;
public abstract class ReactiveCassandraAccessor implements InitializingBean {
/** Logger available to subclasses */
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final Log logger = LogFactory.getLog(getClass());
private CqlExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();

View File

@@ -26,8 +26,8 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.cassandra.ReactiveResultSet;
import org.springframework.data.cassandra.ReactiveSession;
@@ -73,7 +73,7 @@ import com.datastax.oss.driver.api.core.metadata.Metadata;
*/
public class DefaultBridgedReactiveSession implements ReactiveSession {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Log log = LogFactory.getLog(getClass());
private final CqlSession session;
@@ -165,8 +165,8 @@ public class DefaultBridgedReactiveSession implements ReactiveSession {
return Mono.fromCompletionStage(() -> {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Executing statement [%s]", getCql(statement)));
if (log.isDebugEnabled()) {
log.debug(String.format("Executing statement [%s]", getCql(statement)));
}
return this.session.executeAsync(statement);
@@ -194,8 +194,8 @@ public class DefaultBridgedReactiveSession implements ReactiveSession {
return Mono.fromCompletionStage(() -> {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Preparing statement [%s]", getCql(statement)));
if (log.isDebugEnabled()) {
log.debug(String.format("Preparing statement [%s]", getCql(statement)));
}
return this.session.prepareAsync(statement);

View File

@@ -15,8 +15,9 @@
*/
package org.springframework.data.cassandra.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;
@@ -29,7 +30,7 @@ import org.springframework.core.GenericTypeResolver;
*/
public abstract class AbstractCassandraEventListener<E> implements ApplicationListener<CassandraMappingEvent<?>> {
protected static final Logger log = LoggerFactory.getLogger(AbstractCassandraEventListener.class);
protected static final Log log = LogFactory.getLog(AbstractCassandraEventListener.class);
private final Class<?> domainClass;
@@ -101,7 +102,7 @@ public abstract class AbstractCassandraEventListener<E> implements ApplicationLi
*/
public void onBeforeSave(BeforeSaveEvent<E> event) {
if (log.isDebugEnabled()) {
log.debug("onBeforeSave({})", event.getSource());
log.debug(String.format("onBeforeSave(%s)", event.getSource()));
}
}
@@ -112,7 +113,7 @@ public abstract class AbstractCassandraEventListener<E> implements ApplicationLi
*/
public void onAfterSave(AfterSaveEvent<E> event) {
if (log.isDebugEnabled()) {
log.debug("onAfterSave({})", event.getSource());
log.debug(String.format("onAfterSave(%s)", event.getSource()));
}
}
@@ -123,7 +124,7 @@ public abstract class AbstractCassandraEventListener<E> implements ApplicationLi
*/
public void onBeforeDelete(BeforeDeleteEvent<E> event) {
if (log.isDebugEnabled()) {
log.debug("onBeforeDelete({})", event.getSource());
log.debug(String.format("onBeforeDelete(%s)", event.getSource()));
}
}
@@ -134,7 +135,7 @@ public abstract class AbstractCassandraEventListener<E> implements ApplicationLi
*/
public void onAfterDelete(AfterDeleteEvent<E> event) {
if (log.isDebugEnabled()) {
log.debug("onAfterDelete({})", event.getSource());
log.debug(String.format("onAfterDelete(%s)", event.getSource()));
}
}
@@ -145,7 +146,7 @@ public abstract class AbstractCassandraEventListener<E> implements ApplicationLi
*/
public void onAfterLoad(AfterLoadEvent<E> event) {
if (log.isDebugEnabled()) {
log.debug("onAfterLoad({})", event.getSource());
log.debug(String.format("onAfterLoad(%s)", event.getSource()));
}
}
@@ -156,7 +157,7 @@ public abstract class AbstractCassandraEventListener<E> implements ApplicationLi
*/
public void onAfterConvert(AfterConvertEvent<E> event) {
if (log.isDebugEnabled()) {
log.debug("onAfterConvert({})", event.getSource());
log.debug(String.format("onAfterConvert(%s)", event.getSource()));
}
}
}

View File

@@ -21,8 +21,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Optional;
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.cassandra.core.mapping.CassandraMappingContext;
@@ -51,7 +51,7 @@ import org.springframework.util.Assert;
*/
class CassandraQueryCreator extends AbstractQueryCreator<Query, Filter> {
private static final Logger LOG = LoggerFactory.getLogger(CassandraQueryCreator.class);
private static final Log LOG = LogFactory.getLog(CassandraQueryCreator.class);
private final MappingContext<?, CassandraPersistentProperty> mappingContext;

View File

@@ -17,8 +17,8 @@ package org.springframework.data.cassandra.repository.query;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
@@ -42,7 +42,7 @@ import org.springframework.util.ClassUtils;
*/
public abstract class CassandraRepositoryQuerySupport implements RepositoryQuery {
protected final Logger log = LoggerFactory.getLogger(getClass());
protected final Log log = LogFactory.getLog(getClass());
private final CassandraQueryMethod queryMethod;

View File

@@ -19,8 +19,8 @@ package org.springframework.data.cassandra.repository.query;
import java.util.Optional;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.cassandra.core.StatementFactory;
import org.springframework.data.cassandra.core.cql.QueryExtractorDelegate;
@@ -50,7 +50,7 @@ import com.datastax.oss.driver.api.core.cql.Statement;
*/
class QueryStatementCreator {
private static final Logger LOG = LoggerFactory.getLogger(QueryStatementCreator.class);
private static final Log LOG = LogFactory.getLog(QueryStatementCreator.class);
private final CassandraQueryMethod queryMethod;

View File

@@ -18,8 +18,8 @@ package org.springframework.data.cassandra.example;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.core.CassandraTemplate;
@@ -30,7 +30,7 @@ import com.datastax.oss.driver.api.core.CqlSession;
public class CassandraApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(CassandraApplication.class);
private static final Log LOG = LogFactory.getLog(CassandraApplication.class);
private static Person newPerson(String name, int age) {
return new Person(UUID.randomUUID().toString(), name, age);
@@ -44,7 +44,7 @@ public class CassandraApplication {
Person jonDoe = template.insert(newPerson("Jon Doe", 40));
LOGGER.info(template.selectOne(Query.query(Criteria.where("id").is(jonDoe.getId())), Person.class).getId());
LOG.info(template.selectOne(Query.query(Criteria.where("id").is(jonDoe.getId())), Person.class).getId());
template.truncate(Person.class);
cqlSession.close();

View File

@@ -20,8 +20,8 @@ import reactor.core.publisher.Mono;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
import org.springframework.data.cassandra.core.ReactiveCassandraTemplate;
@@ -33,7 +33,7 @@ import com.datastax.oss.driver.api.core.CqlSession;
public class ReactiveCassandraApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(ReactiveCassandraApplication.class);
private static final Log LOG = LogFactory.getLog(ReactiveCassandraApplication.class);
private static Person newPerson(String name, int age) {
return new Person(UUID.randomUUID().toString(), name, age);
@@ -48,7 +48,7 @@ public class ReactiveCassandraApplication {
Mono<Person> jonDoe = template.insert(newPerson("Jon Doe", 40));
jonDoe.flatMap(it -> template.selectOne(Query.query(Criteria.where("id").is(it.getId())), Person.class))
.doOnNext(it -> LOGGER.info(it.toString()))
.doOnNext(it -> LOG.info(it.toString()))
.then(template.truncate(Person.class))
.block();

View File

@@ -33,8 +33,8 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.db.commitlog.CommitLog;
import org.apache.cassandra.service.CassandraDaemon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.FileSystemUtils;
@@ -47,7 +47,7 @@ import org.springframework.util.FileSystemUtils;
@SuppressWarnings("unused")
class EmbeddedCassandraServerHelper {
private static final Logger log = LoggerFactory.getLogger(EmbeddedCassandraServerHelper.class);
private static final Log LOG = LogFactory.getLog(EmbeddedCassandraServerHelper.class);
public static final long DEFAULT_STARTUP_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(20);
private static final String DEFAULT_TMP_DIR = "target/embeddedCassandra";
@@ -155,8 +155,8 @@ class EmbeddedCassandraServerHelper {
checkConfigNameForRestart(file.getAbsolutePath());
log.debug("Starting cassandra...");
log.debug("Initialization needed");
LOG.debug("Starting cassandra...");
LOG.debug("Initialization needed");
System.setProperty("cassandra.config", "file:" + file.getAbsolutePath());
System.setProperty("cassandra-foreground", "true");
@@ -177,12 +177,12 @@ class EmbeddedCassandraServerHelper {
future.get(timeout, MILLISECONDS);
} catch (ExecutionException cause) {
log.error("Cassandra daemon did not start after " + timeout + " ms. Consider increasing the timeout");
LOG.error("Cassandra daemon did not start after " + timeout + " ms. Consider increasing the timeout");
throw new IllegalStateException("Cassandra daemon did not start within timeout", cause);
} catch (InterruptedException cause) {
log.error("Interrupted waiting for Cassandra daemon to start:", cause);
LOG.error("Interrupted waiting for Cassandra daemon to start:", cause);
Thread.currentThread().interrupt();
throw new IllegalStateException(cause);