diff --git a/pom.xml b/pom.xml index bb64762c1..cf316660c 100644 --- a/pom.xml +++ b/pom.xml @@ -85,8 +85,7 @@ localhost embedded - 19042 - + 19042 19160 17001 17000 diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java index 8754a542a..15fc091fa 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java @@ -121,7 +121,7 @@ public abstract class AbstractCassandraConfiguration extends AbstractSessionConf SessionFactoryFactoryBean bean = new SessionFactoryFactoryBean(); - // Initialize the CqlSession reference first since it is required, or must not be null. + // Initialize the CqlSession reference first since it is required, or must not be null! bean.setSession(cqlSession); bean.setConverter(requireBeanOfType(CassandraConverter.class)); @@ -153,6 +153,37 @@ public abstract class AbstractCassandraConfiguration extends AbstractSessionConf return new CassandraCustomConversions(Collections.emptyList()); } + /** + * Configures the Java {@link ClassLoader} used to resolve Cassandra application entity {@link Class types}. + * + * @param classLoader Java {@link ClassLoader} used to resolve Cassandra application entity {@link Class types}; + * may be {@literal null}. + * @see java.lang.ClassLoader + */ + @Override + public void setBeanClassLoader(@Nullable ClassLoader classLoader) { + this.beanClassLoader = classLoader; + } + + /** + * Returns the configured Java {@link ClassLoader} used to resolve Cassandra application entity {@link Class types}. + * + * @return the Java {@link ClassLoader} used to resolve Cassandra application entity {@link Class types}. + * @see java.lang.ClassLoader + * @see java.util.Optional + */ + protected Optional getBeanClassLoader() { + return Optional.ofNullable(this.beanClassLoader); + } + + /** + * Base packages to scan for entities annotated with {@link Table} annotations. By default, returns the package name + * of {@literal this} ({@code this.getClass().getPackage().getName()}. This method must never return {@literal null}. + */ + public String[] getEntityBasePackages() { + return new String[] { getClass().getPackage().getName() }; + } + /** * Return the {@link Set} of initial entity classes. Scans by default the class path using * {@link #getEntityBasePackages()}. Can be overridden by subclasses to skip class path scanning and return a fixed @@ -178,6 +209,15 @@ public abstract class AbstractCassandraConfiguration extends AbstractSessionConf return requireBeanOfType(SessionFactory.class); } + /** + * The {@link SchemaAction} to perform at application startup. Defaults to {@link SchemaAction#NONE}. + * + * @see org.springframework.data.cassandra.config.SchemaAction + */ + public SchemaAction getSchemaAction() { + return SchemaAction.NONE; + } + /** * Creates a {@link KeyspacePopulator} to cleanup the keyspace. * @@ -200,30 +240,6 @@ public abstract class AbstractCassandraConfiguration extends AbstractSessionConf return null; } - @Override - public void setBeanClassLoader(ClassLoader classLoader) { - this.beanClassLoader = classLoader; - } - - protected Optional getBeanClassLoader() { - return Optional.ofNullable(this.beanClassLoader); - } - - /** - * Base packages to scan for entities annotated with {@link Table} annotations. By default, returns the package name - * of {@literal this} ({@code this.getClass().getPackage().getName()}. This method must never return {@literal null}. - */ - public String[] getEntityBasePackages() { - return new String[] { getClass().getPackage().getName() }; - } - - /** - * The {@link SchemaAction} to perform at startup. Defaults to {@link SchemaAction#NONE}. - */ - public SchemaAction getSchemaAction() { - return SchemaAction.NONE; - } - /** * Creates a new {@link ByteArrayResource} given {@code content}. * diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractSessionConfiguration.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractSessionConfiguration.java index 849e86765..65e3589bc 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractSessionConfiguration.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractSessionConfiguration.java @@ -225,10 +225,11 @@ public abstract class AbstractSessionConfiguration implements BeanFactoryAware { } /** - * Returns the list of startup scripts to be run after {@link #getKeyspaceCreations() keyspace creations} and after - * initialization in the {@code system} keyspace. + * Returns the list of CQL scripts to be run on startup after {@link #getKeyspaceCreations() Keyspace creations} + * and after initialization of the {@literal System} Keyspace. * - * @return the list of startup scripts, may be {@link Collections#emptyList() empty} but never {@literal null}. + * @return the list of CQL scripts to be run on startup; may be {@link Collections#emptyList() empty} + * but never {@literal null}. * @deprecated since 3.0; Declare a * {@link org.springframework.data.cassandra.core.cql.session.init.SessionFactoryInitializer} bean instead. */ @@ -238,10 +239,11 @@ public abstract class AbstractSessionConfiguration implements BeanFactoryAware { } /** - * Returns the list of shutdown scripts to be run after {@link #getKeyspaceDrops() keyspace drops} and right before - * shutdown in the {@code system} keyspace. + * Returns the list of CQL scripts to be run on shutdown after {@link #getKeyspaceDrops() Keyspace drops} + * and right before shutdown of the {@code System} Keyspace. * - * @return the list of shutdown scripts, may be {@link Collections#emptyList() empty} but never {@literal null}. + * @return the list of CQL scripts to be run on shutdown; may be {@link Collections#emptyList() empty} + * but never {@literal null}. * @deprecated since 3.0; Declare a * {@link org.springframework.data.cassandra.core.cql.session.init.SessionFactoryInitializer} bean instead. */ @@ -286,12 +288,12 @@ public abstract class AbstractSessionConfiguration implements BeanFactoryAware { CassandraDriverOptions options = new CassandraDriverOptions(); - if (StringUtils.hasText(getClusterName())) { - options.add(DefaultDriverOption.SESSION_NAME, getClusterName()); - } - else if (StringUtils.hasText(getSessionName())) { + if (StringUtils.hasText(getSessionName())) { options.add(DefaultDriverOption.SESSION_NAME, getSessionName()); } + else if (StringUtils.hasText(getClusterName())) { + options.add(DefaultDriverOption.SESSION_NAME, getClusterName()); + } CompressionType compressionType = getCompressionType();