Class AbstractCassandraConfiguration
java.lang.Object
org.springframework.data.cassandra.config.AbstractSessionConfiguration
org.springframework.data.cassandra.config.AbstractCassandraConfiguration
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,BeanFactoryAware
- Direct Known Subclasses:
AbstractReactiveCassandraConfiguration
@Configuration
public abstract class AbstractCassandraConfiguration
extends AbstractSessionConfiguration
implements BeanClassLoaderAware
Base class for Spring Data Cassandra configuration using JavaConfig.
- Author:
- Alex Shvid, Matthew T. Adams, John Blum, Mark Paluch
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreates aCassandraConverter
using the configuredcassandraMapping()
.Return theMappingContext
instance to map Entities toJava Objects
.cassandraSessionFactory
(com.datastax.oss.driver.api.core.CqlSession cqlSession) Creates aSessionFactoryFactoryBean
that provides aSessionFactory
.Creates aCassandraAdminTemplate
.Register customConverter
s in aCustomConversions
object if required.protected Optional<ClassLoader>
Returns the configured JavaClassLoader
used to resolve Cassandra application entitytypes
.String[]
Base packages to scan for entities annotated withTable
annotations.Return theSet
of initial entity classes.protected SessionFactory
Returns the initializedCqlSession
instance.TheSchemaAction
to perform at application startup.protected KeyspacePopulator
Creates aKeyspacePopulator
to cleanup the keyspace.protected KeyspacePopulator
Creates aKeyspacePopulator
to initialize the keyspace.protected ByteArrayResource
Creates a newByteArrayResource
givencontent
.void
setBeanClassLoader
(ClassLoader classLoader) Configures the JavaClassLoader
used to resolve Cassandra application entitytypes
.Methods inherited from class org.springframework.data.cassandra.config.AbstractSessionConfiguration
cassandraSession, cqlTemplate, getBeanFactory, getClusterName, getCompressionType, getContactPoints, getDriverConfigLoaderBuilderConfigurer, getDriverConfigurationResource, getKeyspaceCreations, getKeyspaceDrops, getKeyspaceName, getLocalDataCenter, getPort, getRequiredSession, getSessionBuilderConfigurer, getSessionName, getShutdownScripts, getStartupScripts, requireBeanOfType, setBeanFactory
-
Constructor Details
-
AbstractCassandraConfiguration
public AbstractCassandraConfiguration()
-
-
Method Details
-
cassandraConverter
Creates aCassandraConverter
using the configuredcassandraMapping()
. Will apply all specifiedcustomConversions()
.- Returns:
CassandraConverter
used to convert Java and Cassandra value types during the mapping process.- See Also:
-
cassandraMapping
Return theMappingContext
instance to map Entities toJava Objects
.- Throws:
ClassNotFoundException
- if the Cassandra Entity class type identified by name cannot be found during the scan.- See Also:
-
cassandraSessionFactory
@Bean public SessionFactoryFactoryBean cassandraSessionFactory(com.datastax.oss.driver.api.core.CqlSession cqlSession) Creates aSessionFactoryFactoryBean
that provides aSessionFactory
. The lifecycle ofSessionFactoryFactoryBean
initializes theschema
in theconfigured keyspace
. -
cassandraTemplate
Creates aCassandraAdminTemplate
. -
customConversions
Register customConverter
s in aCustomConversions
object if required. TheseCustomConversions
will be registered with thecassandraConverter()
andcassandraMapping()
. Returns an emptyCustomConversions
instance by default.- Returns:
- must not be null.
- Since:
- 1.5
-
setBeanClassLoader
Configures the JavaClassLoader
used to resolve Cassandra application entitytypes
.- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
- Parameters:
classLoader
- JavaClassLoader
used to resolve Cassandra application entitytypes
; may be null.- See Also:
-
getBeanClassLoader
Returns the configured JavaClassLoader
used to resolve Cassandra application entitytypes
.- Returns:
- the Java
ClassLoader
used to resolve Cassandra application entitytypes
. - See Also:
-
getEntityBasePackages
Base packages to scan for entities annotated withTable
annotations. By default, returns the package name of this (this.getClass().getPackage().getName()
. This method must never return null. -
getInitialEntitySet
Return theSet
of initial entity classes. Scans by default the class path usinggetEntityBasePackages()
. Can be overridden by subclasses to skip class path scanning and return a fixed set of entity classes.- Returns:
Set
of initial entity classes.- Throws:
ClassNotFoundException
- if the entity scan fails.- Since:
- 2.0
- See Also:
-
getRequiredSessionFactory
Returns the initializedCqlSession
instance.- Overrides:
getRequiredSessionFactory
in classAbstractSessionConfiguration
- Returns:
- the
CqlSession
. - Throws:
IllegalStateException
- if the session factory is not initialized.
-
getSchemaAction
TheSchemaAction
to perform at application startup. Defaults toSchemaAction.NONE
.- See Also:
-
keyspaceCleaner
Creates aKeyspacePopulator
to cleanup the keyspace.- Returns:
- the
KeyspacePopulator
ornull
if none configured. - See Also:
-
keyspacePopulator
Creates aKeyspacePopulator
to initialize the keyspace.- Returns:
- the
KeyspacePopulator
ornull
if none configured. - See Also:
-
scriptOf
Creates a newByteArrayResource
givencontent
.- Parameters:
content
- the script content.- Returns:
- a new
ByteArrayResource
forcontent
. - Since:
- 3.0
-