@Configuration public abstract class AbstractCassandraConfiguration extends AbstractSessionConfiguration implements BeanClassLoaderAware
Constructor and Description |
---|
AbstractCassandraConfiguration() |
Modifier and Type | Method and Description |
---|---|
CassandraConverter |
cassandraConverter()
Creates a
CassandraConverter using the configured cassandraMapping() . |
CassandraMappingContext |
cassandraMapping()
Return the
MappingContext instance to map Entities to Java Objects . |
SessionFactoryFactoryBean |
cassandraSessionFactory(com.datastax.oss.driver.api.core.CqlSession cqlSession)
Creates a
SessionFactoryFactoryBean that provides a SessionFactory . |
CassandraAdminTemplate |
cassandraTemplate()
Creates a
CassandraAdminTemplate . |
CassandraCustomConversions |
customConversions()
Register custom
Converter s in a CustomConversions object if required. |
protected Optional<ClassLoader> |
getBeanClassLoader()
Returns the configured Java
ClassLoader used to resolve Cassandra application entity types . |
String[] |
getEntityBasePackages()
Base packages to scan for entities annotated with
Table annotations. |
protected Set<Class<?>> |
getInitialEntitySet()
Return the
Set of initial entity classes. |
protected SessionFactory |
getRequiredSessionFactory()
Returns the initialized
CqlSession instance. |
SchemaAction |
getSchemaAction()
The
SchemaAction to perform at application startup. |
protected KeyspacePopulator |
keyspaceCleaner()
Creates a
KeyspacePopulator to cleanup the keyspace. |
protected KeyspacePopulator |
keyspacePopulator()
Creates a
KeyspacePopulator to initialize the keyspace. |
protected ByteArrayResource |
scriptOf(String content)
Creates a new
ByteArrayResource given content . |
void |
setBeanClassLoader(ClassLoader classLoader)
Configures the Java
ClassLoader used to resolve Cassandra application entity types . |
cassandraSession, cqlTemplate, getBeanFactory, getClusterName, getCompressionType, getContactPoints, getDriverConfigLoaderBuilderConfigurer, getDriverConfigurationResource, getKeyspaceCreations, getKeyspaceDrops, getKeyspaceName, getLocalDataCenter, getPort, getRequiredSession, getSessionBuilderConfigurer, getSessionName, getShutdownScripts, getStartupScripts, requireBeanOfType, setBeanFactory
@Bean public CassandraConverter cassandraConverter()
CassandraConverter
using the configured cassandraMapping()
.
Will apply all specified customConversions()
.CassandraConverter
used to convert Java and Cassandra value types during the mapping process.cassandraMapping()
,
customConversions()
@Bean public CassandraMappingContext cassandraMapping() throws ClassNotFoundException
MappingContext
instance to map Entities to Java Objects
.ClassNotFoundException
- if the Cassandra Entity class type identified by name
cannot be found during the scan.CassandraMappingContext
@Bean public SessionFactoryFactoryBean cassandraSessionFactory(com.datastax.oss.driver.api.core.CqlSession cqlSession)
SessionFactoryFactoryBean
that provides a SessionFactory
. The lifecycle of
SessionFactoryFactoryBean
initializes the schema
in the
configured keyspace
.@Bean public CassandraAdminTemplate cassandraTemplate()
CassandraAdminTemplate
.@Bean public CassandraCustomConversions customConversions()
Converter
s in a CustomConversions
object if required. These
CustomConversions
will be registered with the cassandraConverter()
and cassandraMapping()
. Returns an empty CustomConversions
instance by default.public void setBeanClassLoader(@Nullable ClassLoader classLoader)
ClassLoader
used to resolve Cassandra application entity types
.setBeanClassLoader
in interface BeanClassLoaderAware
classLoader
- Java ClassLoader
used to resolve Cassandra application entity types
; may
be null.ClassLoader
protected Optional<ClassLoader> getBeanClassLoader()
ClassLoader
used to resolve Cassandra application entity types
.ClassLoader
used to resolve Cassandra application entity types
.ClassLoader
,
Optional
public String[] getEntityBasePackages()
Table
annotations. By default, returns the package name
of this (this.getClass().getPackage().getName()
. This method must never return null.protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException
Set
of initial entity classes. Scans by default the class path using
getEntityBasePackages()
. Can be overridden by subclasses to skip class path scanning and return a fixed
set of entity classes.Set
of initial entity classes.ClassNotFoundException
- if the entity scan fails.getEntityBasePackages()
,
CassandraEntityClassScanner
protected SessionFactory getRequiredSessionFactory()
CqlSession
instance.getRequiredSessionFactory
in class AbstractSessionConfiguration
CqlSession
.IllegalStateException
- if the session factory is not initialized.public SchemaAction getSchemaAction()
SchemaAction
to perform at application startup. Defaults to SchemaAction.NONE
.SchemaAction
@Nullable protected KeyspacePopulator keyspaceCleaner()
KeyspacePopulator
to cleanup the keyspace.KeyspacePopulator
or null
if none configured.ResourceKeyspacePopulator
@Nullable protected KeyspacePopulator keyspacePopulator()
KeyspacePopulator
to initialize the keyspace.KeyspacePopulator
or null
if none configured.ResourceKeyspacePopulator
protected ByteArrayResource scriptOf(String content)
ByteArrayResource
given content
.content
- the script content.ByteArrayResource
for content
.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.