From 4df8fd1fce1826ff927c27db977cd6f6f3e0c05d Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jan 2017 18:15:14 +0100 Subject: [PATCH] DATACASS-330 - Polishing. Move Reactive Session support to session package. Reorder fields according their visibility. --- .../cassandra/core/AsyncCqlTemplate.java | 4 +- .../cassandra/core/CqlTemplate.java | 4 +- .../cassandra/core/ReactiveCqlOperations.java | 3 +- .../cassandra/core/ReactiveCqlTemplate.java | 4 ++ .../ReactivePreparedStatementCallback.java | 3 +- .../ReactivePreparedStatementCreator.java | 8 +-- .../core/ReactiveResultSetExtractor.java | 3 +- .../ReactiveRowMapperResultSetExtractor.java | 7 +-- .../core/ReactiveSessionCallback.java | 3 +- .../core/ReactiveStatementCallback.java | 3 +- .../DefaultBridgedReactiveSession.java | 9 +++- .../DefaultReactiveSessionFactory.java | 6 ++- .../core/session/DefaultSessionFactory.java | 3 ++ .../core/{ => session}/ReactiveResultSet.java | 13 +++-- .../core/{ => session}/ReactiveSession.java | 8 +-- .../{ => session}/ReactiveSessionFactory.java | 6 ++- .../cassandra/core/session/package-info.java | 2 +- .../cassandra/support/CassandraAccessor.java | 13 ++--- .../support/ReactiveCassandraAccessor.java | 8 +-- ...ridgedReactiveSessionIntegrationTests.java | 2 + ...efaultBridgedReactiveSessionUnitTests.java | 1 + .../ReactiveCqlTemplateIntegrationTests.java | 3 ++ .../core/ReactiveCqlTemplateUnitTests.java | 4 ++ ...bstractReactiveCassandraConfiguration.java | 12 ++--- .../core/AsyncCassandraOperations.java | 2 +- .../cassandra/core/CassandraTemplate.java | 2 + .../core/ReactiveCassandraTemplate.java | 50 ++++++++++--------- ...tiveCassandraTemplateIntegrationTests.java | 2 +- .../ReactiveCassandraTemplateUnitTests.java | 4 +- ...ssandraRepositoriesRegistrarUnitTests.java | 2 +- ...iveStringBasedCassandraQueryUnitTests.java | 2 +- 31 files changed, 117 insertions(+), 79 deletions(-) rename spring-cql/src/main/java/org/springframework/cassandra/core/{ => session}/DefaultBridgedReactiveSession.java (96%) rename spring-cql/src/main/java/org/springframework/cassandra/core/{ => session}/DefaultReactiveSessionFactory.java (87%) rename spring-cql/src/main/java/org/springframework/cassandra/core/{ => session}/ReactiveResultSet.java (94%) rename spring-cql/src/main/java/org/springframework/cassandra/core/{ => session}/ReactiveSession.java (99%) rename spring-cql/src/main/java/org/springframework/cassandra/core/{ => session}/ReactiveSessionFactory.java (88%) diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java index 048247a99..cd0414328 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java @@ -80,8 +80,8 @@ import com.google.common.util.concurrent.Futures; public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOperations { /** - * Constructs a new, uninitialized {@link AsyncCqlTemplate}. Note: The {@link Session} has to be set before using the - * instance. + * Constructs a new, uninitialized {@link AsyncCqlTemplate}. Note: The {@link SessionFactory} has to be set before + * using the instance. * * @see #setSessionFactory(SessionFactory) */ diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java b/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java index 9abd25e5b..ec6417598 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java @@ -80,8 +80,8 @@ import com.datastax.driver.core.exceptions.DriverException; public class CqlTemplate extends CassandraAccessor implements CqlOperations { /** - * Constructs a new, uninitialized {@link CqlTemplate}. Note: The {@link Session} has to be set before using the - * instance. + * Constructs a new, uninitialized {@link CqlTemplate}. Note: The {@link SessionFactory} has to be set before using + * the instance. * * @see #setSessionFactory(SessionFactory) */ diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java index 98beec224..132dc664e 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -18,6 +18,7 @@ package org.springframework.cassandra.core; import java.util.Map; import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.session.ReactiveResultSet; import org.springframework.dao.DataAccessException; import org.springframework.dao.IncorrectResultSizeDataAccessException; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java index 02db51754..262b59cd7 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java @@ -22,6 +22,10 @@ import java.util.Map; import java.util.function.Function; import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.session.DefaultReactiveSessionFactory; +import org.springframework.cassandra.core.session.ReactiveResultSet; +import org.springframework.cassandra.core.session.ReactiveSession; +import org.springframework.cassandra.core.session.ReactiveSessionFactory; import org.springframework.cassandra.support.ReactiveCassandraAccessor; import org.springframework.dao.DataAccessException; import org.springframework.dao.support.DataAccessUtils; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCallback.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCallback.java index 66598c836..b44087bfb 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCallback.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -16,6 +16,7 @@ package org.springframework.cassandra.core; import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.dao.DataAccessException; import com.datastax.driver.core.PreparedStatement; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCreator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCreator.java index 47e45021d..8f6f4c64b 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCreator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactivePreparedStatementCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -15,11 +15,13 @@ */ package org.springframework.cassandra.core; +import reactor.core.publisher.Mono; + +import org.springframework.cassandra.core.session.ReactiveSession; + import com.datastax.driver.core.PreparedStatement; import com.datastax.driver.core.exceptions.DriverException; -import reactor.core.publisher.Mono; - /** * One of the two central callback interfaces used by the {@link ReactiveCqlTemplate} class. This interface creates a * {@link PreparedStatement} given a {@link ReactiveSession}, provided by the {@link ReactiveCqlTemplate} class. diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveResultSetExtractor.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveResultSetExtractor.java index 1a701405c..e14892243 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveResultSetExtractor.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveResultSetExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -16,6 +16,7 @@ package org.springframework.cassandra.core; import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.session.ReactiveResultSet; import org.springframework.dao.DataAccessException; import com.datastax.driver.core.exceptions.DriverException; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveRowMapperResultSetExtractor.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveRowMapperResultSetExtractor.java index 8c86d24db..b419f9efd 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveRowMapperResultSetExtractor.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveRowMapperResultSetExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -15,14 +15,15 @@ */ package org.springframework.cassandra.core; +import reactor.core.publisher.Mono; + import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.session.ReactiveResultSet; import org.springframework.dao.DataAccessException; import org.springframework.util.Assert; import com.datastax.driver.core.exceptions.DriverException; -import reactor.core.publisher.Mono; - /** * Adapter implementation of the {@link ReactiveResultSetExtractor} interface that delegates to a {@link RowMapper} * which is supposed to create an object for each row. Each object is emitted through the {@link Publisher} of this diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSessionCallback.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSessionCallback.java index 74a3d4e19..26a8f03e4 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSessionCallback.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSessionCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -16,6 +16,7 @@ package org.springframework.cassandra.core; import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.dao.DataAccessException; import com.datastax.driver.core.Statement; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveStatementCallback.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveStatementCallback.java index 1de249b00..593d31343 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveStatementCallback.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveStatementCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -16,6 +16,7 @@ package org.springframework.cassandra.core; import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.dao.DataAccessException; import com.datastax.driver.core.Statement; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/DefaultBridgedReactiveSession.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultBridgedReactiveSession.java similarity index 96% rename from spring-cql/src/main/java/org/springframework/cassandra/core/DefaultBridgedReactiveSession.java rename to spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultBridgedReactiveSession.java index 4ff4867f2..3f5b57966 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/DefaultBridgedReactiveSession.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultBridgedReactiveSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 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,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.core; +package org.springframework.cassandra.core.session; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Scheduler; +import reactor.core.scheduler.Schedulers; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/DefaultReactiveSessionFactory.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultReactiveSessionFactory.java similarity index 87% rename from spring-cql/src/main/java/org/springframework/cassandra/core/DefaultReactiveSessionFactory.java rename to spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultReactiveSessionFactory.java index 19275fc0b..7a76dd92c 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/DefaultReactiveSessionFactory.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultReactiveSessionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 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,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.core; +package org.springframework.cassandra.core.session; + +import org.springframework.cassandra.core.ReactiveRowMapperResultSetExtractor; /** * Default implementation of {@link ReactiveSessionFactory}. diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultSessionFactory.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultSessionFactory.java index 68e8e1f87..9acfd944f 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultSessionFactory.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultSessionFactory.java @@ -45,6 +45,9 @@ public class DefaultSessionFactory implements SessionFactory { this.session = session; } + /* (non-Javadoc) + * @see org.springframework.cassandra.core.session.SessionFactory#getSession() + */ @Override public Session getSession() { return session; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveResultSet.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveResultSet.java similarity index 94% rename from spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveResultSet.java rename to spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveResultSet.java index baca0d8ab..87ee5ac6f 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveResultSet.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveResultSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 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,24 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.core; +package org.springframework.cassandra.core.session; + +import reactor.core.publisher.Flux; import java.util.List; import com.datastax.driver.core.ColumnDefinitions; import com.datastax.driver.core.ExecutionInfo; import com.datastax.driver.core.Row; -import com.datastax.driver.core.Statement; - -import reactor.core.publisher.Flux; /** * The reactive result of a query. *

* The retrieval of the rows of a {@link ReactiveResultSet} is generally paged (a first page of result is fetched and * the next one is only fetched once all the results of the first one has been consumed). The size of the pages can be - * configured either globally through {@link QueryOptions#setFetchSize} or per-statement with - * {@link Statement#setFetchSize}. + * configured either globally through {@link com.datastax.driver.core.QueryOptions#setFetchSize} or per-statement with + * {@link com.datastax.driver.core.Statement#setFetchSize}. *

* Please note however that this {@link ReactiveResultSet} paging is not available with the version 1 of the native * protocol (i.e. with Cassandra 1.2 or if version 1 has been explicitly requested through diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSession.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveSession.java similarity index 99% rename from spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSession.java rename to spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveSession.java index 74f23f5af..4aaa3bb8b 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSession.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 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,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.core; +package org.springframework.cassandra.core.session; + +import reactor.core.publisher.Mono; import java.io.Closeable; import java.util.Map; @@ -27,8 +29,6 @@ import com.datastax.driver.core.exceptions.QueryExecutionException; import com.datastax.driver.core.exceptions.QueryValidationException; import com.datastax.driver.core.exceptions.UnsupportedFeatureException; -import reactor.core.publisher.Mono; - /** * A session holds connections to a Cassandra cluster, allowing it to be queried. {@link ReactiveSession} executes * queries and prepares statements in a reactive style returning results wrapped in {@link Mono} and diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSessionFactory.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveSessionFactory.java similarity index 88% rename from spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSessionFactory.java rename to spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveSessionFactory.java index 233937ad0..f5434d9c7 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveSessionFactory.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/ReactiveSessionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 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,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.core; +package org.springframework.cassandra.core.session; + +import org.springframework.cassandra.core.ReactiveCqlTemplate; /** * Strategy interface to produce {@link ReactiveSession} instances. diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/session/package-info.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/package-info.java index 268a7666b..6c7c42000 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/session/package-info.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/package-info.java @@ -1,5 +1,5 @@ /** - * Provides utility classes for simple {@link com.datastax.driver.core.Session} access and various simple DataSource + * Provides utility classes for simple {@link com.datastax.driver.core.Session} access and various session * implementations. * * @author Mark Paluch diff --git a/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraAccessor.java b/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraAccessor.java index 595aa4b9c..efe7e97e1 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraAccessor.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraAccessor.java @@ -64,22 +64,23 @@ public class CassandraAccessor implements InitializingBean { */ private final static Statement DEFAULTS = QueryBuilder.select().from("DEFAULT"); + /** Logger available to subclasses */ + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + protected CassandraExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator(); + /** * If this variable is set to a non-negative value, it will be used for setting the {@code fetchSize} property on * statements used for query processing. */ private int fetchSize = -1; - protected CassandraExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator(); - /** * If this variable is set to a value, it will be used for setting the {@code consistencyLevel} property on statements * used for query processing. */ private com.datastax.driver.core.ConsistencyLevel consistencyLevel; - protected final Logger logger = LoggerFactory.getLogger(getClass()); - /** * If this variable is set to a value, it will be used for setting the {@code retryPolicy} property on statements used * for query processing. @@ -438,8 +439,8 @@ public class CassandraAccessor implements InitializingBean { this.rowCallbackHandler = rowCallbackHandler; } - /** - * @inheritDoc + /* (non-Javadoc) + * @see org.springframework.cassandra.core.ResultSetExtractor#extractData(com.datastax.driver.core.ResultSet) */ @Override public Object extractData(ResultSet resultSet) { diff --git a/spring-cql/src/main/java/org/springframework/cassandra/support/ReactiveCassandraAccessor.java b/spring-cql/src/main/java/org/springframework/cassandra/support/ReactiveCassandraAccessor.java index bd8962b82..ca18d00d7 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/support/ReactiveCassandraAccessor.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/support/ReactiveCassandraAccessor.java @@ -18,7 +18,8 @@ package org.springframework.cassandra.support; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; -import org.springframework.cassandra.core.ReactiveSessionFactory; +import org.springframework.cassandra.core.session.ReactiveSession; +import org.springframework.cassandra.core.session.ReactiveSessionFactory; import org.springframework.cassandra.core.support.CQLExceptionTranslator; import org.springframework.dao.DataAccessException; import org.springframework.util.Assert; @@ -27,15 +28,14 @@ import com.datastax.driver.core.exceptions.DriverException; /** * Base class for {@link org.springframework.cassandra.core.ReactiveCqlTemplate} and other CQL-accessing DAO helpers, - * defining common properties such as {@link org.springframework.cassandra.core.ReactiveSessionFactory} and exception - * translator. + * defining common properties such as {@link ReactiveSessionFactory} and exception translator. *

* Not intended to be used directly. * * @author Mark Paluch * @since 2.0 * @see InitializingBean - * @see org.springframework.cassandra.core.ReactiveSession + * @see ReactiveSession * @see org.springframework.cassandra.core.ReactiveCqlTemplate */ public abstract class ReactiveCassandraAccessor implements InitializingBean { diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java index 998f5b849..9181a1ca5 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java @@ -22,6 +22,8 @@ import reactor.core.scheduler.Schedulers; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; +import org.springframework.cassandra.core.session.ReactiveResultSet; import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import com.datastax.driver.core.KeyspaceMetadata; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java index 95915109b..c5b63df7b 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java @@ -29,6 +29,7 @@ import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java index 995137b54..969b9a6d0 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java @@ -24,6 +24,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; +import org.springframework.cassandra.core.session.DefaultReactiveSessionFactory; +import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import com.datastax.driver.core.querybuilder.QueryBuilder; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateUnitTests.java index 07e83c900..35958dbaf 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateUnitTests.java @@ -31,6 +31,10 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.cassandra.core.session.DefaultReactiveSessionFactory; +import org.springframework.cassandra.core.session.ReactiveResultSet; +import org.springframework.cassandra.core.session.ReactiveSession; +import org.springframework.cassandra.core.session.ReactiveSessionFactory; import org.springframework.cassandra.support.exception.CassandraConnectionFailureException; import org.springframework.cassandra.support.exception.CassandraInvalidQueryException; import org.springframework.dao.IncorrectResultSizeDataAccessException; diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/java/AbstractReactiveCassandraConfiguration.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/java/AbstractReactiveCassandraConfiguration.java index c655661ba..f0d8ae7bf 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/java/AbstractReactiveCassandraConfiguration.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/java/AbstractReactiveCassandraConfiguration.java @@ -15,19 +15,19 @@ */ package org.springframework.data.cassandra.config.java; -import org.springframework.cassandra.core.DefaultBridgedReactiveSession; -import org.springframework.cassandra.core.DefaultReactiveSessionFactory; +import reactor.core.scheduler.Schedulers; + import org.springframework.cassandra.core.ReactiveCqlOperations; import org.springframework.cassandra.core.ReactiveCqlTemplate; -import org.springframework.cassandra.core.ReactiveSession; -import org.springframework.cassandra.core.ReactiveSessionFactory; +import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; +import org.springframework.cassandra.core.session.DefaultReactiveSessionFactory; +import org.springframework.cassandra.core.session.ReactiveSession; +import org.springframework.cassandra.core.session.ReactiveSessionFactory; import org.springframework.context.annotation.Bean; import org.springframework.data.cassandra.core.CassandraAdminTemplate; import org.springframework.data.cassandra.core.ReactiveCassandraOperations; import org.springframework.data.cassandra.core.ReactiveCassandraTemplate; -import reactor.core.scheduler.Schedulers; - /** * Extension to {@link AbstractCassandraConfiguration} providing Spring Data Cassandra configuration for Spring Data's * Reactive Cassandra support using JavaConfig. diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraOperations.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraOperations.java index 74f3b2e3e..7ffd61de4 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraOperations.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraOperations.java @@ -40,7 +40,7 @@ import com.datastax.driver.core.Statement; public interface AsyncCassandraOperations { /** - * Expose the underlying {@link AsyncCqlOperationsOperations} to allow asynchronous CQL operations. + * Expose the underlying {@link AsyncCqlOperations} to allow asynchronous CQL operations. * * @return the underlying {@link AsyncCqlOperations}. * @see AsyncCqlOperations diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java index 76f0c0907..08cfce653 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java @@ -69,7 +69,9 @@ import com.datastax.driver.core.querybuilder.Update; public class CassandraTemplate implements CassandraOperations { private final CassandraConverter converter; + private final CassandraMappingContext mappingContext; + private final CqlOperations cqlOperations; /** diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java index 8fd81b679..755451fcc 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java @@ -15,6 +15,30 @@ */ package org.springframework.data.cassandra.core; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.reactivestreams.Publisher; +import org.springframework.cassandra.core.CqlProvider; +import org.springframework.cassandra.core.QueryOptions; +import org.springframework.cassandra.core.ReactiveCqlOperations; +import org.springframework.cassandra.core.ReactiveCqlTemplate; +import org.springframework.cassandra.core.ReactiveSessionCallback; +import org.springframework.cassandra.core.WriteOptions; +import org.springframework.cassandra.core.cql.CqlIdentifier; +import org.springframework.cassandra.core.session.DefaultReactiveSessionFactory; +import org.springframework.cassandra.core.session.ReactiveResultSet; +import org.springframework.cassandra.core.session.ReactiveSession; +import org.springframework.cassandra.core.session.ReactiveSessionFactory; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.data.cassandra.convert.CassandraConverter; +import org.springframework.data.cassandra.convert.MappingCassandraConverter; +import org.springframework.data.cassandra.mapping.CassandraMappingContext; +import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; +import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; + import com.datastax.driver.core.Session; import com.datastax.driver.core.SimpleStatement; import com.datastax.driver.core.Statement; @@ -26,30 +50,6 @@ import com.datastax.driver.core.querybuilder.Select; import com.datastax.driver.core.querybuilder.Truncate; import com.datastax.driver.core.querybuilder.Update; -import org.reactivestreams.Publisher; -import org.springframework.cassandra.core.CqlProvider; -import org.springframework.cassandra.core.DefaultReactiveSessionFactory; -import org.springframework.cassandra.core.QueryOptions; -import org.springframework.cassandra.core.ReactiveCqlOperations; -import org.springframework.cassandra.core.ReactiveCqlTemplate; -import org.springframework.cassandra.core.ReactiveResultSet; -import org.springframework.cassandra.core.ReactiveSession; -import org.springframework.cassandra.core.ReactiveSessionCallback; -import org.springframework.cassandra.core.ReactiveSessionFactory; -import org.springframework.cassandra.core.WriteOptions; -import org.springframework.cassandra.core.cql.CqlIdentifier; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.cassandra.convert.CassandraConverter; -import org.springframework.data.cassandra.convert.MappingCassandraConverter; -import org.springframework.data.cassandra.mapping.CassandraMappingContext; -import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * 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, @@ -68,7 +68,9 @@ import reactor.core.publisher.Mono; public class ReactiveCassandraTemplate implements ReactiveCassandraOperations { private final CassandraConverter converter; + private final CassandraMappingContext mappingContext; + private final ReactiveCqlOperations cqlOperations; /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java index 7b5592e86..397de5bd3 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java @@ -22,8 +22,8 @@ import reactor.core.scheduler.Schedulers; import org.junit.Before; import org.junit.Test; -import org.springframework.cassandra.core.DefaultBridgedReactiveSession; import org.springframework.cassandra.core.ReactiveCqlTemplate; +import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.domain.Person; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java index 56743e28c..e1a7397db 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java @@ -33,8 +33,8 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.springframework.cassandra.core.ReactiveResultSet; -import org.springframework.cassandra.core.ReactiveSession; +import org.springframework.cassandra.core.session.ReactiveResultSet; +import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.cassandra.support.exception.CassandraConnectionFailureException; import org.springframework.data.cassandra.domain.Person; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java index 015c1ef0d..909d1c745 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.*; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.core.ReactiveSession; +import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan.Filter; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java index 2e156c9c0..60687e580 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java @@ -26,8 +26,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.springframework.cassandra.core.ReactiveCqlOperations; -import org.springframework.cassandra.core.ReactiveSession; import org.springframework.cassandra.core.ReactiveSessionCallback; +import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.ReactiveCassandraOperations; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;