DATACASS-446 - Resolve package cycles.
* Resolve cycle between o.s.d.c.cql.core and o.s.d.c.cql.support via CassandraAccessor. * Resolve cycle between o.s.d.c.cql.core.support and o.s.d.c.cql.support via CQLExceptionTranslator. * Resolve cycle between o.s.d.c.cql.config and o.s.d.c.cql.core.keyspace via KeyspaceAttributes/DataCenterReplication.
This commit is contained in:
@@ -38,7 +38,7 @@ import org.springframework.data.cql.core.QueryOptions;
|
||||
import org.springframework.data.cql.core.WriteOptions;
|
||||
import org.springframework.data.cql.core.session.DefaultSessionFactory;
|
||||
import org.springframework.data.cql.core.session.SessionFactory;
|
||||
import org.springframework.data.cql.core.support.CQLExceptionTranslator;
|
||||
import org.springframework.data.cql.support.CqlExceptionTranslator;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
@@ -87,7 +87,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations {
|
||||
|
||||
private final CassandraMappingContext mappingContext;
|
||||
|
||||
private final CQLExceptionTranslator exceptionTranslator;
|
||||
private final CqlExceptionTranslator exceptionTranslator;
|
||||
|
||||
private final StatementFactory statementFactory;
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.cql.config.CassandraCqlClusterFactoryBean;
|
||||
import org.springframework.data.cql.config.KeyspaceActionSpecificationFactoryBean;
|
||||
import org.springframework.data.cql.config.KeyspaceAttributes;
|
||||
import org.springframework.data.cql.config.MultiLevelSetFlattenerFactoryBean;
|
||||
import org.springframework.data.cql.config.PoolingOptionsFactoryBean;
|
||||
import org.springframework.data.cql.config.SocketOptionsFactoryBean;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceActionSpecification;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceAttributes;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.support.DataAccessUtils;
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
import org.springframework.data.cql.core.session.SessionFactory;
|
||||
import org.springframework.data.cql.support.CassandraAccessor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
@@ -77,7 +76,7 @@ import com.google.common.util.concurrent.Futures;
|
||||
* @see RowMapper
|
||||
* @see org.springframework.dao.support.PersistenceExceptionTranslator
|
||||
*/
|
||||
public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOperations {
|
||||
public class AsyncCqlTemplate extends CqlTemplateSupport implements AsyncCqlOperations {
|
||||
|
||||
/**
|
||||
* Create a new, uninitialized {@link AsyncCqlTemplate}. Note: The {@link SessionFactory} has to be set before using
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.function.Function;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.support.DataAccessUtils;
|
||||
import org.springframework.data.cql.core.session.SessionFactory;
|
||||
import org.springframework.data.cql.support.CassandraAccessor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.datastax.driver.core.BoundStatement;
|
||||
@@ -77,7 +76,7 @@ import com.datastax.driver.core.exceptions.DriverException;
|
||||
* @see RowMapper
|
||||
* @see org.springframework.dao.support.PersistenceExceptionTranslator
|
||||
*/
|
||||
public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
public class CqlTemplate extends CqlTemplateSupport implements CqlOperations {
|
||||
|
||||
/**
|
||||
* Create a new, uninitialized {@link CqlTemplate}. Note: The {@link SessionFactory} has to be set before using the
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cql.core;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.springframework.data.cql.support.CassandraAccessor;
|
||||
|
||||
import com.datastax.driver.core.ResultSet;
|
||||
|
||||
/**
|
||||
* Support class for CQL template implementation providing utility methods and overridable hook methods.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class CqlTemplateSupport extends CassandraAccessor {
|
||||
|
||||
/**
|
||||
* Create a new arg-based PreparedStatementSetter using the args passed in. By default, we'll create an
|
||||
* {@link ArgumentPreparedStatementBinder}. This method allows for the creation to be overridden by subclasses.
|
||||
*
|
||||
* @param args object array with arguments
|
||||
* @return the new {@link PreparedStatementBinder} to use
|
||||
*/
|
||||
protected PreparedStatementBinder newPreparedStatementBinder(Object[] args) {
|
||||
return new ArgumentPreparedStatementBinder(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the {@link ResultSetExtractor} initialized with and adapting the given
|
||||
* {@link RowCallbackHandler}.
|
||||
*
|
||||
* @param rowCallbackHandler {@link RowCallbackHandler} to adapt as a {@link ResultSetExtractor}.
|
||||
* @return a {@link ResultSetExtractor} implementation adapting an instance of the {@link RowCallbackHandler}.
|
||||
* @see org.springframework.data.cql.core.AsyncCqlTemplate.RowCallbackHandlerResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.ResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.RowCallbackHandler
|
||||
*/
|
||||
protected RowCallbackHandlerResultSetExtractor newResultSetExtractor(RowCallbackHandler rowCallbackHandler) {
|
||||
return new RowCallbackHandlerResultSetExtractor(rowCallbackHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the {@link ResultSetExtractor} initialized with and adapting the given
|
||||
* {@link RowMapper}.
|
||||
*
|
||||
* @param rowMapper {@link RowMapper} to adapt as a {@link ResultSetExtractor}.
|
||||
* @return a {@link ResultSetExtractor} implementation adapting an instance of the {@link RowMapper}.
|
||||
* @see org.springframework.data.cql.core.ResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.RowMapper
|
||||
* @see org.springframework.data.cql.core.RowMapperResultSetExtractor
|
||||
*/
|
||||
protected <T> RowMapperResultSetExtractor<T> newResultSetExtractor(RowMapper<T> rowMapper) {
|
||||
return new RowMapperResultSetExtractor<>(rowMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the {@link ResultSetExtractor} initialized with and adapting the given
|
||||
* {@link RowMapper}.
|
||||
*
|
||||
* @param rowMapper {@link RowMapper} to adapt as a {@link ResultSetExtractor}.
|
||||
* @param rowsExpected number of expected rows in the {@link ResultSet}.
|
||||
* @return a {@link ResultSetExtractor} implementation adapting an instance of the {@link RowMapper}.
|
||||
* @see org.springframework.data.cql.core.ResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.RowMapper
|
||||
* @see org.springframework.data.cql.core.RowMapperResultSetExtractor
|
||||
*/
|
||||
protected <T> RowMapperResultSetExtractor<T> newResultSetExtractor(RowMapper<T> rowMapper, int rowsExpected) {
|
||||
return new RowMapperResultSetExtractor<>(rowMapper, rowsExpected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RowMapper for reading columns as key-value pairs.
|
||||
*
|
||||
* @return the RowMapper to use
|
||||
* @see ColumnMapRowMapper
|
||||
*/
|
||||
protected RowMapper<Map<String, Object>> newColumnMapRowMapper() {
|
||||
return new ColumnMapRowMapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RowMapper for reading result objects from a single column.
|
||||
*
|
||||
* @param requiredType the type that each result object is expected to match
|
||||
* @return the RowMapper to use
|
||||
* @see SingleColumnRowMapper
|
||||
*/
|
||||
protected <T> RowMapper<T> newSingleColumnRowMapper(Class<T> requiredType) {
|
||||
return SingleColumnRowMapper.newInstance(requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine CQL from potential provider object.
|
||||
*
|
||||
* @param cqlProvider object that's potentially a {@link CqlProvider}
|
||||
* @return the CQL string, or {@code null}
|
||||
* @see CqlProvider
|
||||
*/
|
||||
protected static String toCql(Object cqlProvider) {
|
||||
return Optional.ofNullable(cqlProvider) //
|
||||
.filter(o -> o instanceof CqlProvider) //
|
||||
.map(o -> (CqlProvider) o) //
|
||||
.map(CqlProvider::getCql) //
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter to enable use of a {@link RowCallbackHandler} inside a {@link ResultSetExtractor}.
|
||||
*/
|
||||
protected static class RowCallbackHandlerResultSetExtractor implements ResultSetExtractor<Object> {
|
||||
|
||||
private final RowCallbackHandler rowCallbackHandler;
|
||||
|
||||
protected RowCallbackHandlerResultSetExtractor(RowCallbackHandler rowCallbackHandler) {
|
||||
this.rowCallbackHandler = rowCallbackHandler;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
@see org.springframework.cassandra.core.ResultSetExtractor#extractData(com.datastax.driver.core.ResultSet)
|
||||
*/
|
||||
@Override
|
||||
public Object extractData(ResultSet resultSet) {
|
||||
|
||||
StreamSupport.stream(resultSet.spliterator(), false).forEach(rowCallbackHandler::processRow);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,8 @@ import static org.springframework.data.cql.core.CqlStringUtils.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.cql.config.KeyspaceAttributes;
|
||||
import org.springframework.data.cql.core.keyspace.CreateKeyspaceSpecification;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceAttributes;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceOption;
|
||||
import org.springframework.data.cql.core.keyspace.Option;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cql.core.keyspace;
|
||||
|
||||
import org.springframework.data.cql.config.DataCenterReplication;
|
||||
import org.springframework.data.cql.core.KeyspaceIdentifier;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceOption.ReplicationStrategy;
|
||||
import org.springframework.data.cql.core.util.MapBuilder;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cql.config;
|
||||
package org.springframework.data.cql.core.keyspace;
|
||||
|
||||
/**
|
||||
* Simple data structure to be used when setting the replication factor for a given data center.
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -13,15 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cql.config;
|
||||
package org.springframework.data.cql.core.keyspace;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.cql.core.keyspace.DefaultOption;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceOption;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceOption.ReplicationStrategy;
|
||||
import org.springframework.data.cql.core.keyspace.Option;
|
||||
import org.springframework.data.cql.core.util.MapBuilder;
|
||||
|
||||
/**
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* CQL support classes.
|
||||
*/
|
||||
package org.springframework.data.cql.core.support;
|
||||
@@ -15,31 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.cql.support;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.cql.core.ArgumentPreparedStatementBinder;
|
||||
import org.springframework.data.cql.core.ColumnMapRowMapper;
|
||||
import org.springframework.data.cql.core.CqlProvider;
|
||||
import org.springframework.data.cql.core.PreparedStatementBinder;
|
||||
import org.springframework.data.cql.core.ResultSetExtractor;
|
||||
import org.springframework.data.cql.core.RowCallbackHandler;
|
||||
import org.springframework.data.cql.core.RowMapper;
|
||||
import org.springframework.data.cql.core.RowMapperResultSetExtractor;
|
||||
import org.springframework.data.cql.core.SingleColumnRowMapper;
|
||||
import org.springframework.data.cql.core.session.DefaultSessionFactory;
|
||||
import org.springframework.data.cql.core.session.SessionFactory;
|
||||
import org.springframework.data.cql.core.support.CQLExceptionTranslator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.datastax.driver.core.ConsistencyLevel;
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import com.datastax.driver.core.ResultSet;
|
||||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.Statement;
|
||||
import com.datastax.driver.core.exceptions.DriverException;
|
||||
@@ -69,7 +54,7 @@ public class CassandraAccessor implements InitializingBean {
|
||||
/** Logger available to subclasses */
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected CQLExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();
|
||||
protected CqlExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();
|
||||
|
||||
/**
|
||||
* If this variable is set to a non-negative value, it will be used for setting the {@code fetchSize} property on
|
||||
@@ -123,9 +108,9 @@ public class CassandraAccessor implements InitializingBean {
|
||||
* Exception Hierarchy.
|
||||
*
|
||||
* @param exceptionTranslator exception translator to set; must not be {@literal null}.
|
||||
* @see CQLExceptionTranslator
|
||||
* @see CqlExceptionTranslator
|
||||
*/
|
||||
public void setExceptionTranslator(CQLExceptionTranslator exceptionTranslator) {
|
||||
public void setExceptionTranslator(CqlExceptionTranslator exceptionTranslator) {
|
||||
|
||||
Assert.notNull(exceptionTranslator, "CQLExceptionTranslator must not be null");
|
||||
this.exceptionTranslator = exceptionTranslator;
|
||||
@@ -136,9 +121,9 @@ public class CassandraAccessor implements InitializingBean {
|
||||
* Exception Hierarchy.
|
||||
*
|
||||
* @return the Cassandra exception translator.
|
||||
* @see CQLExceptionTranslator
|
||||
* @see CqlExceptionTranslator
|
||||
*/
|
||||
public CQLExceptionTranslator getExceptionTranslator() {
|
||||
public CqlExceptionTranslator getExceptionTranslator() {
|
||||
|
||||
Assert.state(this.exceptionTranslator != null, "CQLExceptionTranslator was not properly initialized");
|
||||
|
||||
@@ -295,102 +280,6 @@ public class CassandraAccessor implements InitializingBean {
|
||||
return statement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new arg-based PreparedStatementSetter using the args passed in. By default, we'll create an
|
||||
* {@link ArgumentPreparedStatementBinder}. This method allows for the creation to be overridden by subclasses.
|
||||
*
|
||||
* @param args object array with arguments
|
||||
* @return the new {@link PreparedStatementBinder} to use
|
||||
*/
|
||||
protected PreparedStatementBinder newPreparedStatementBinder(Object[] args) {
|
||||
return new ArgumentPreparedStatementBinder(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the {@link ResultSetExtractor} initialized with and adapting the given
|
||||
* {@link RowCallbackHandler}.
|
||||
*
|
||||
* @param rowCallbackHandler {@link RowCallbackHandler} to adapt as a {@link ResultSetExtractor}.
|
||||
* @return a {@link ResultSetExtractor} implementation adapting an instance of the {@link RowCallbackHandler}.
|
||||
* @see org.springframework.data.cql.core.AsyncCqlTemplate.RowCallbackHandlerResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.ResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.RowCallbackHandler
|
||||
*/
|
||||
protected RowCallbackHandlerResultSetExtractor newResultSetExtractor(RowCallbackHandler rowCallbackHandler) {
|
||||
return new RowCallbackHandlerResultSetExtractor(rowCallbackHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the {@link ResultSetExtractor} initialized with and adapting the given
|
||||
* {@link RowMapper}.
|
||||
*
|
||||
* @param rowMapper {@link RowMapper} to adapt as a {@link ResultSetExtractor}.
|
||||
* @return a {@link ResultSetExtractor} implementation adapting an instance of the {@link RowMapper}.
|
||||
* @see org.springframework.data.cql.core.ResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.RowMapper
|
||||
* @see org.springframework.data.cql.core.RowMapperResultSetExtractor
|
||||
*/
|
||||
protected <T> RowMapperResultSetExtractor<T> newResultSetExtractor(RowMapper<T> rowMapper) {
|
||||
return new RowMapperResultSetExtractor<>(rowMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the {@link ResultSetExtractor} initialized with and adapting the given
|
||||
* {@link RowMapper}.
|
||||
*
|
||||
* @param rowMapper {@link RowMapper} to adapt as a {@link ResultSetExtractor}.
|
||||
* @param rowsExpected number of expected rows in the {@link ResultSet}.
|
||||
* @return a {@link ResultSetExtractor} implementation adapting an instance of the {@link RowMapper}.
|
||||
* @see org.springframework.data.cql.core.ResultSetExtractor
|
||||
* @see org.springframework.data.cql.core.RowMapper
|
||||
* @see org.springframework.data.cql.core.RowMapperResultSetExtractor
|
||||
*/
|
||||
protected <T> RowMapperResultSetExtractor<T> newResultSetExtractor(RowMapper<T> rowMapper, int rowsExpected) {
|
||||
return new RowMapperResultSetExtractor<>(rowMapper, rowsExpected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RowMapper for reading columns as key-value pairs.
|
||||
*
|
||||
* @return the RowMapper to use
|
||||
* @see ColumnMapRowMapper
|
||||
*/
|
||||
protected RowMapper<Map<String, Object>> newColumnMapRowMapper() {
|
||||
return new ColumnMapRowMapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RowMapper for reading result objects from a single column.
|
||||
*
|
||||
* @param requiredType the type that each result object is expected to match
|
||||
* @return the RowMapper to use
|
||||
* @see SingleColumnRowMapper
|
||||
*/
|
||||
protected <T> RowMapper<T> newSingleColumnRowMapper(Class<T> requiredType) {
|
||||
return SingleColumnRowMapper.newInstance(requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine CQL from potential provider object.
|
||||
*
|
||||
* @param cqlProvider object that's potentially a {@link CqlProvider}
|
||||
* @return the CQL string, or {@code null}
|
||||
* @see CqlProvider
|
||||
*/
|
||||
protected static String toCql(Object cqlProvider) {
|
||||
return Optional.ofNullable(cqlProvider) //
|
||||
.filter(o -> o instanceof CqlProvider) //
|
||||
.map(o -> (CqlProvider) o) //
|
||||
.map(CqlProvider::getCql) //
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
protected void logDebug(String logMessage, Object... array) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(logMessage, array);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the given {@link DriverException} into a generic {@link DataAccessException}.
|
||||
* <p>
|
||||
@@ -436,28 +325,4 @@ public class CassandraAccessor implements InitializingBean {
|
||||
|
||||
return getExceptionTranslator().translate(task, cql, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter to enable use of a {@link RowCallbackHandler} inside a {@link ResultSetExtractor}.
|
||||
*/
|
||||
protected static class RowCallbackHandlerResultSetExtractor implements ResultSetExtractor<Object> {
|
||||
|
||||
private final RowCallbackHandler rowCallbackHandler;
|
||||
|
||||
protected RowCallbackHandlerResultSetExtractor(RowCallbackHandler rowCallbackHandler) {
|
||||
this.rowCallbackHandler = rowCallbackHandler;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
@see org.springframework.cassandra.core.ResultSetExtractor#extractData(com.datastax.driver.core.ResultSet)
|
||||
*/
|
||||
@Override
|
||||
public Object extractData(ResultSet resultSet) {
|
||||
|
||||
StreamSupport.stream(resultSet.spliterator(), false).forEach(rowCallbackHandler::processRow);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.dao.TransientDataAccessResourceException;
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
import org.springframework.data.cql.core.support.CQLExceptionTranslator;
|
||||
import org.springframework.data.cql.support.exception.*;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -47,7 +46,7 @@ import com.datastax.driver.core.exceptions.*;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CassandraExceptionTranslator implements CQLExceptionTranslator {
|
||||
public class CassandraExceptionTranslator implements CqlExceptionTranslator {
|
||||
|
||||
private static final Set<String> CONNECTION_FAILURE_TYPES = new HashSet<>(
|
||||
Arrays.asList("NoHostAvailableException", "ConnectionException", "OperationTimedOutException",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cql.core.support;
|
||||
package org.springframework.data.cql.support;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
@@ -29,7 +29,7 @@ import com.datastax.driver.core.exceptions.DriverException;
|
||||
* @see 2.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface CQLExceptionTranslator extends PersistenceExceptionTranslator {
|
||||
public interface CqlExceptionTranslator extends PersistenceExceptionTranslator {
|
||||
|
||||
/**
|
||||
* Translate the given {@link DriverException} into a generic {@link DataAccessException}.
|
||||
@@ -21,7 +21,6 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.cql.core.session.ReactiveSession;
|
||||
import org.springframework.data.cql.core.session.ReactiveSessionFactory;
|
||||
import org.springframework.data.cql.core.support.CQLExceptionTranslator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.datastax.driver.core.exceptions.DriverException;
|
||||
@@ -43,7 +42,7 @@ public abstract class ReactiveCassandraAccessor implements InitializingBean {
|
||||
/** Logger available to subclasses */
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private CQLExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();
|
||||
private CqlExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();
|
||||
|
||||
private ReactiveSessionFactory sessionFactory;
|
||||
|
||||
@@ -76,7 +75,7 @@ public abstract class ReactiveCassandraAccessor implements InitializingBean {
|
||||
* @see CassandraExceptionTranslator
|
||||
* @see DataAccessException
|
||||
*/
|
||||
public void setExceptionTranslator(CQLExceptionTranslator exceptionTranslator) {
|
||||
public void setExceptionTranslator(CqlExceptionTranslator exceptionTranslator) {
|
||||
|
||||
Assert.notNull(exceptionTranslator, "CQLExceptionTranslator must not be null");
|
||||
|
||||
@@ -89,7 +88,7 @@ public abstract class ReactiveCassandraAccessor implements InitializingBean {
|
||||
* @return the Cassandra exception translator.
|
||||
* @see CassandraExceptionTranslator
|
||||
*/
|
||||
public CQLExceptionTranslator getExceptionTranslator() {
|
||||
public CqlExceptionTranslator getExceptionTranslator() {
|
||||
return this.exceptionTranslator;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.cql.AbstractKeyspaceCreatingIntegrationTest;
|
||||
import org.springframework.data.cql.config.KeyspaceAttributes;
|
||||
import org.springframework.data.cql.core.keyspace.CreateKeyspaceSpecification;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceAttributes;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceOption;
|
||||
import org.springframework.data.cql.support.AbstractTestJavaConfig;
|
||||
import org.springframework.data.cql.support.KeyspaceTestUtils;
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.cql.config.KeyspaceAttributes;
|
||||
import org.springframework.data.cql.core.keyspace.CreateKeyspaceSpecification;
|
||||
import org.springframework.data.cql.core.keyspace.DefaultOption;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceAttributes;
|
||||
import org.springframework.data.cql.core.keyspace.KeyspaceOption;
|
||||
import org.springframework.data.cql.core.keyspace.Option;
|
||||
import org.springframework.data.cql.support.RandomKeySpaceName;
|
||||
|
||||
Reference in New Issue
Block a user