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 configuredcassandraMapping().Returns the givenCassandraManagedTypesobject holding the initial entity set.Deprecated, for removal: This API element is subject to removal in a future version.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 KeyspacePopulatorCreates aKeyspacePopulatorto cleanup the keyspace.protected KeyspacePopulatorCreates aKeyspacePopulatorto initialize the keyspace.protected ByteArrayResourceCreates a newByteArrayResourcegivencontent.voidsetBeanClassLoader(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 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 aCassandraConverterusing the configuredcassandraMapping(). 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
-
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 theMappingContextinstance to map Entities toJava Objects.- Throws:
ClassNotFoundException- See Also:
-
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. -
cassandraTemplate
Creates aCassandraAdminTemplate. -
customConversions
Register customConverters in aCustomConversionsobject if required. TheseCustomConversionswill be registered with thecassandraConverter()andcassandraMapping(). 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
Base packages to scan for entities annotated withTableannotations. By default, returns the package name of this (this.getClass().getPackage().getName(). This method must never return null. -
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 cleanup 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
-
cassandraMappingContext(CassandraManagedTypes)instead.