Class AbstractCassandraConfiguration
java.lang.Object
org.springframework.data.cassandra.config.AbstractSessionConfiguration
org.springframework.data.cassandra.config.AbstractCassandraConfiguration
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.BeanFactoryAware
- Direct Known Subclasses:
AbstractReactiveCassandraConfiguration
@Configuration
public abstract class AbstractCassandraConfiguration
extends AbstractSessionConfiguration
implements org.springframework.beans.factory.BeanClassLoaderAware
Base class for Spring Data Cassandra configuration using JavaConfig.
- Author:
- Alex Shvid, Matthew T. Adams, John Blum, Mark Paluch, Ammar Khaku
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreates aCassandraConverter
using the configuredcassandraMapping()
.Returns the givenCassandraManagedTypes
object holding the initial entity set.Deprecated, for removal: This API element is subject to removal in a future version.cassandraMappingContext
(CassandraManagedTypes cassandraManagedTypes) 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 org.springframework.core.io.ByteArrayResource
Creates a newByteArrayResource
givencontent
.void
setBeanClassLoader
(ClassLoader classLoader) Configures the JavaClassLoader
used to resolve Cassandra application entitytypes
.protected UserTypeResolver
userTypeResolver
(com.datastax.oss.driver.api.core.CqlSession cqlSession) Creates a newUserTypeResolver
from the givenCqlSession
.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:
-
cassandraManagedTypes
Returns the givenCassandraManagedTypes
object holding the initial entity set.- Returns:
- new instance of
CassandraManagedTypes
. - Throws:
ClassNotFoundException
- Since:
- 4.0
-
cassandraMapping
@Deprecated(since="4.0", forRemoval=true) public CassandraMappingContext cassandraMapping() throws ClassNotFoundExceptionDeprecated, for removal: This API element is subject to removal in a future version.since 4.0, usecassandraMappingContext(CassandraManagedTypes)
instead.Return theMappingContext
instance to map Entities toJava Objects
.- Throws:
ClassNotFoundException
- See Also:
-
cassandraMappingContext
@Bean public CassandraMappingContext cassandraMappingContext(CassandraManagedTypes cassandraManagedTypes) Return theMappingContext
instance to map Entities toJava Objects
.- 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 interfaceorg.springframework.beans.factory.BeanClassLoaderAware
- 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
-
userTypeResolver
Creates a newUserTypeResolver
from the givenCqlSession
. Uses by default the configuredkeyspace name
.- Parameters:
cqlSession
- the CassandraCqlSession
to use.- Returns:
- a new
SimpleUserTypeResolver
. - Since:
- 3.4.3
-
cassandraMappingContext(CassandraManagedTypes)
instead.