DATACASS-713 - Rename Session and SessionFactory bean names with cassandra prefix.
We now register the Session under cassandraSession and SessionFactory with cassandraSessionFactory as bean name. ReactiveSession and ReactiveSessionFactory beans are named reactiveCassandraSession respective reactiveCassandraSessionFactory. Beans are consistently named using Java and XML-based configuration avoiding potential clashes with other data integrations that use Session or SessionFactory beans.
This commit is contained in:
@@ -87,7 +87,7 @@ public abstract class AbstractCassandraConfiguration extends AbstractSessionConf
|
||||
* @see #keyspaceCleaner()
|
||||
*/
|
||||
@Bean
|
||||
public SessionFactoryFactoryBean sessionFactory(CqlSession cqlSession) {
|
||||
public SessionFactoryFactoryBean cassandraSessionFactory(CqlSession cqlSession) {
|
||||
|
||||
SessionFactoryFactoryBean bean = new SessionFactoryFactoryBean();
|
||||
|
||||
|
||||
@@ -45,24 +45,24 @@ public abstract class AbstractReactiveCassandraConfiguration extends AbstractCas
|
||||
* expose Cassandra access in a reactive style.
|
||||
*
|
||||
* @return the {@link ReactiveSession}.
|
||||
* @see #session()
|
||||
* @see #cassandraSession()
|
||||
* @see DefaultBridgedReactiveSession
|
||||
*/
|
||||
@Bean
|
||||
public ReactiveSession reactiveSession() {
|
||||
public ReactiveSession reactiveCassandraSession() {
|
||||
return new DefaultBridgedReactiveSession(getRequiredSession());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link ReactiveSessionFactory} to be used by the {@link ReactiveCassandraTemplate}. Uses the
|
||||
* {@link ReactiveSession} instance configured in {@link #reactiveSession()}.
|
||||
* {@link ReactiveSession} instance configured in {@link #reactiveCassandraSession()}.
|
||||
*
|
||||
* @return the {@link ReactiveSessionFactory}.
|
||||
* @see #reactiveSession()
|
||||
* @see #reactiveCassandraSession()
|
||||
* @see #reactiveCassandraTemplate()
|
||||
*/
|
||||
@Bean
|
||||
public ReactiveSessionFactory reactiveSessionFactory() {
|
||||
public ReactiveSessionFactory reactiveCassandraSessionFactory() {
|
||||
return new DefaultReactiveSessionFactory(beanFactory.getBean(ReactiveSession.class));
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class AbstractReactiveCassandraConfiguration extends AbstractCas
|
||||
* Creates a {@link CassandraAdminTemplate}.
|
||||
*
|
||||
* @return the {@link ReactiveCassandraTemplate}.
|
||||
* @see #reactiveSessionFactory()
|
||||
* @see #reactiveCassandraSessionFactory()
|
||||
* @see #cassandraConverter()
|
||||
*/
|
||||
@Bean
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractReactiveCassandraConfiguration extends AbstractCas
|
||||
* Creates a {@link ReactiveCqlTemplate} using the configured {@link ReactiveSessionFactory}.
|
||||
*
|
||||
* @return the {@link ReactiveCqlOperations}.
|
||||
* @see #reactiveSessionFactory()
|
||||
* @see #reactiveCassandraSessionFactory()
|
||||
*/
|
||||
@Bean
|
||||
public ReactiveCqlTemplate reactiveCqlTemplate() {
|
||||
|
||||
@@ -220,7 +220,7 @@ public abstract class AbstractSessionConfiguration implements BeanFactoryAware {
|
||||
* @see #getShutdownScripts()
|
||||
*/
|
||||
@Bean
|
||||
public CqlSessionFactoryBean session() {
|
||||
public CqlSessionFactoryBean cassandraSession() {
|
||||
|
||||
CqlSessionFactoryBean bean = new CqlSessionFactoryBean();
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class JavaConfigAuditingTests extends AbstractAuditingTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CqlSessionFactoryBean session() {
|
||||
public CqlSessionFactoryBean cassandraSession() {
|
||||
|
||||
CqlSessionFactoryBean sessionFactoryBean = mock(CqlSessionFactoryBean.class);
|
||||
CqlSession session = mock(CqlSession.class);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2020 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
|
||||
*
|
||||
* https://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.cassandra.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
|
||||
import org.springframework.data.cassandra.repository.support.IntegrationTestConfig;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link AbstractReactiveCassandraConfiguration}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = IntegrationTestConfig.class)
|
||||
public class ReactiveCassandraConfigurationIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
|
||||
|
||||
@Autowired BeanFactory beanFactory;
|
||||
|
||||
@Test // DATACASS-713
|
||||
public void shouldContainCassandraSessionBean() {
|
||||
assertThat(beanFactory.containsBean(DefaultCqlBeanNames.SESSION)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACASS-713
|
||||
public void shouldContainCassandraSessionFactoryBean() {
|
||||
assertThat(beanFactory.containsBean(DefaultCqlBeanNames.SESSION_FACTORY)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACASS-713
|
||||
public void shouldContainReactiveCassandraSessionBean() {
|
||||
assertThat(beanFactory.containsBean("reactiveCassandraSession")).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACASS-713
|
||||
public void shouldContainReactiveCassandraSessionFactoryBean() {
|
||||
assertThat(beanFactory.containsBean("reactiveCassandraSessionFactory")).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class IntegrationTestConfig extends AbstractReactiveCassandraConfiguratio
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public CqlSessionFactoryBean session() {
|
||||
public CqlSessionFactoryBean cassandraSession() {
|
||||
|
||||
SharedCqlSessionFactoryBean bean = new SharedCqlSessionFactoryBean();
|
||||
|
||||
@@ -72,8 +72,8 @@ public class IntegrationTestConfig extends AbstractReactiveCassandraConfiguratio
|
||||
|
||||
@Bean(destroyMethod = "")
|
||||
@Override
|
||||
public ReactiveSession reactiveSession() {
|
||||
return super.reactiveSession();
|
||||
public ReactiveSession reactiveCassandraSession() {
|
||||
return super.reactiveCassandraSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -355,7 +355,7 @@ If you want to initialize a database using XML configuration and you can provide
|
||||
====
|
||||
[source,xml,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
<cassandra:initialize-keyspace session-factory-ref="sessionFactory">
|
||||
<cassandra:initialize-keyspace session-factory-ref="cassandraSessionFactory">
|
||||
<cassandra:script location="classpath:com/foo/cql/db-schema.cql"/>
|
||||
<cassandra:script location="classpath:com/foo/cql/db-test-data.cql"/>
|
||||
</cassandra:initialize-keyspace>
|
||||
@@ -380,7 +380,7 @@ The following example gets a value from a system property:
|
||||
====
|
||||
[source,xml,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
<cassandra:initialize-keyspace session-factory-ref="sessionFactory"
|
||||
<cassandra:initialize-keyspace session-factory-ref="cassandraSessionFactory"
|
||||
enabled="#{systemProperties.INITIALIZE_KEYSPACE}"> <1>
|
||||
<cassandra:script location="..."/>
|
||||
</cassandra:initialize-database>
|
||||
@@ -394,7 +394,7 @@ To this end, you can control the ability of the initializer to ignore certain er
|
||||
====
|
||||
[source,xml,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
<cassandra:initialize-keyspace session-factory-ref="sessionFactory" ignore-failures="DROPS">
|
||||
<cassandra:initialize-keyspace session-factory-ref="cassandraSessionFactory" ignore-failures="DROPS">
|
||||
<cassandra:script location="..."/>
|
||||
</cassandra:initialize-database>
|
||||
----
|
||||
@@ -422,7 +422,7 @@ Alternatively, you can use XML to configure the `SessionFactoryInitializer`:
|
||||
====
|
||||
[source,xml,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
<cassandra:initialize-keyspace session-factory-ref="sessionFactory" separator="@@"> <1>
|
||||
<cassandra:initialize-keyspace session-factory-ref="cassandraSessionFactory" separator="@@"> <1>
|
||||
<cassandra:script location="classpath:com/myapp/cql/db-schema.cql" separator=";"/> <2>
|
||||
<cassandra:script location="classpath:com/myapp/cql/db-test-data-1.cql"/>
|
||||
<cassandra:script location="classpath:com/myapp/cql/db-test-data-2.cql"/>
|
||||
|
||||
@@ -136,7 +136,9 @@ Please also migrate raw UDT and tuple types to the new driver types `UdtValue` r
|
||||
Paging state now uses `ByteBuffer`.
|
||||
* `SimpleUserTypeResolver` accepts `CqlSession` instead of `Cluster`.
|
||||
* `SimpleTupleTypeFactory` was migrated to `enum`. `SimpleTupleTypeFactory.INSTANCE` no longer requires a `Cluster`/`CqlSession` context.
|
||||
* Introduction of `StatementBuilder` to functionally build statements as the QueryBuilder API uses immutable statement types
|
||||
* Introduction of `StatementBuilder` to functionally build statements as the QueryBuilder API uses immutable statement types.
|
||||
* `Session` bean renamed from `session` to `cassandraSession` and `SessionFactory` bean renamed from `sessionFactory` to `cassandraSessionFactory`.
|
||||
* `ReactiveSession` bean renamed from `reactiveSession` to `reactiveCassandraSession` and `ReactiveSessionFactory` bean renamed from `reactiveSessionFactory` to `reactiveCassandraSessionFactory`.
|
||||
|
||||
== Deprecations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user