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, Ammar Khaku
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates aCassandraConverterusing the configuredcassandraMappingContext(CassandraManagedTypes).Returns the givenCassandraManagedTypesobject holding the initial entity set.cassandraMappingContext(CassandraManagedTypes cassandraManagedTypes) Return theMappingContextinstance to map Entities toJava Objects.cassandraSessionFactory(com.datastax.oss.driver.api.core.CqlSession cqlSession) Creates aSessionFactoryFactoryBeanthat provides aSessionFactory.Creates aCassandraAdminTemplate.Register customConverters in aCustomConversionsobject if required.protected Optional<ClassLoader> Returns the configured JavaClassLoaderused to resolve Cassandra application entitytypes.String[]Base packages to scan for entities annotated withTableannotations.Return theSetof initial entity classes.protected SessionFactoryReturns the initializedCqlSessioninstance.TheSchemaActionto perform at application startup.protected @Nullable KeyspacePopulatorCreates aKeyspacePopulatorto clean up the keyspace.protected @Nullable KeyspacePopulatorCreates aKeyspacePopulatorto initialize the keyspace.protected ByteArrayResourceCreates a newByteArrayResourcegivencontent.voidsetBeanClassLoader(@Nullable ClassLoader classLoader) Configures the JavaClassLoaderused to resolve Cassandra application entitytypes.protected UserTypeResolveruserTypeResolver(com.datastax.oss.driver.api.core.CqlSession cqlSession) Creates a newUserTypeResolverfrom the givenCqlSession.Methods inherited from class AbstractSessionConfiguration
cassandraSession, cqlTemplate, getBeanFactory, getCompressionType, getContactPoints, getDriverConfigLoaderBuilderConfigurer, getDriverConfigurationResource, getKeyspaceCreations, getKeyspaceDrops, getKeyspaceName, getLocalDataCenter, getPort, getRequiredSession, getSessionBuilderConfigurer, getSessionName, requireBeanOfType, setBeanFactory
-
Constructor Details
-
AbstractCassandraConfiguration
public AbstractCassandraConfiguration()
-
-
Method Details
-
cassandraConverter
Creates aCassandraConverterusing the configuredcassandraMappingContext(CassandraManagedTypes). Will apply all specifiedcustomConversions().- Returns:
CassandraConverterused to convert Java and Cassandra value types during the mapping process.- See Also:
-
cassandraManagedTypes
Returns the givenCassandraManagedTypesobject holding the initial entity set.- Returns:
- new instance of
CassandraManagedTypes. - Throws:
ClassNotFoundException- Since:
- 4.0
-
cassandraMappingContext
@Bean public CassandraMappingContext cassandraMappingContext(CassandraManagedTypes cassandraManagedTypes) Return theMappingContextinstance to map Entities toJava Objects.- See Also:
-
cassandraSessionFactory
@Bean public SessionFactoryFactoryBean cassandraSessionFactory(com.datastax.oss.driver.api.core.CqlSession cqlSession) Creates aSessionFactoryFactoryBeanthat provides aSessionFactory. The lifecycle ofSessionFactoryFactoryBeaninitializes theschemain theconfigured keyspace.- Returns:
- the
SessionFactoryFactoryBean. - See Also:
-
cassandraTemplate
Creates aCassandraAdminTemplate. -
customConversions
Register customConverters in aCustomConversionsobject if required. TheseCustomConversionswill be registered with thecassandraConverter()andcassandraMappingContext(CassandraManagedTypes). Returns an emptyCustomConversionsinstance by default.- Returns:
- must not be null.
- Since:
- 1.5
-
setBeanClassLoader
Configures the JavaClassLoaderused to resolve Cassandra application entitytypes.- Specified by:
setBeanClassLoaderin interfaceBeanClassLoaderAware- Parameters:
classLoader- JavaClassLoaderused to resolve Cassandra application entitytypes; may be null.- See Also:
-
getBeanClassLoader
Returns the configured JavaClassLoaderused to resolve Cassandra application entitytypes.- Returns:
- the Java
ClassLoaderused to resolve Cassandra application entitytypes. - See Also:
-
getEntityBasePackages
-
getInitialEntitySet
Return theSetof 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:
Setof initial entity classes.- Throws:
ClassNotFoundException- if the entity scan fails.- Since:
- 2.0
- See Also:
-
getRequiredSessionFactory
Returns the initializedCqlSessioninstance.- Overrides:
getRequiredSessionFactoryin classAbstractSessionConfiguration- Returns:
- the
CqlSession. - Throws:
IllegalStateException- if the session factory is not initialized.
-
getSchemaAction
TheSchemaActionto perform at application startup. Defaults toSchemaAction.NONE.- See Also:
-
keyspaceCleaner
Creates aKeyspacePopulatorto clean up the keyspace.- Returns:
- the
KeyspacePopulatorornullif none configured. - See Also:
-
keyspacePopulator
Creates aKeyspacePopulatorto initialize the keyspace.- Returns:
- the
KeyspacePopulatorornullif none configured. - See Also:
-
scriptOf
Creates a newByteArrayResourcegivencontent.- Parameters:
content- the script content.- Returns:
- a new
ByteArrayResourceforcontent. - Since:
- 3.0
-
userTypeResolver
Creates a newUserTypeResolverfrom the givenCqlSession. Uses by default the configuredkeyspace name.- Parameters:
cqlSession- the CassandraCqlSessionto use.- Returns:
- a new
SimpleUserTypeResolver. - Since:
- 3.4.3
-