Class AbstractSessionConfiguration
java.lang.Object
org.springframework.data.cassandra.config.AbstractSessionConfiguration
- All Implemented Interfaces:
Aware, BeanFactoryAware
- Direct Known Subclasses:
AbstractCassandraConfiguration
@Configuration
public abstract class AbstractSessionConfiguration
extends Object
implements BeanFactoryAware
Spring
Configuration
class used to configure a Cassandra client application CqlSession
connected to a
Cassandra cluster. Enables a Cassandra Keyspace to be specified along with the ability to execute arbitrary CQL on
startup as well as shutdown.- Author:
- Matthew T. Adams, John Blum, Mark Paluch
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates aCqlSessionFactoryBean
that provides a CassandraCqlSession
.Creates aCqlTemplate
configured withgetRequiredSessionFactory()
.protected BeanFactory
Returns the configured reference to theBeanFactory
.protected @Nullable CompressionType
Returns theCompressionType
.protected String
Returns the Cassandra contact points.protected @Nullable DriverConfigLoaderBuilderConfigurer
Returns theDriverConfigLoaderBuilderConfigurer
.protected @Nullable Resource
Returns theResource
pointing to a driver configuration file.protected List
<CreateKeyspaceSpecification> Returns the list of keyspace creations to be run right after initialization.protected List
<DropKeyspaceSpecification> Returns the list of keyspace drops to be run before shutdown.protected abstract String
Return the name of the keyspace to connect to.protected @Nullable String
Returns the local data center name used forLoadBalancingPolicy
, defaulting todatacenter1
.protected int
getPort()
Returns the Cassandra port.protected com.datastax.oss.driver.api.core.CqlSession
Returns the initializedCqlSession
instance.protected SessionFactory
Returns the initializedCqlSession
instance.protected @Nullable SessionBuilderConfigurer
Returns theSessionBuilderConfigurer
.protected @Nullable String
Returns the session name.protected <T> T
requireBeanOfType
(Class<T> beanType) Gets a required bean of the providedtype
from theBeanFactory
.void
setBeanFactory
(BeanFactory beanFactory) Configures a reference to theBeanFactory
.
-
Constructor Details
-
AbstractSessionConfiguration
public AbstractSessionConfiguration()
-
-
Method Details
-
setBeanFactory
Configures a reference to theBeanFactory
.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- reference to theBeanFactory
.- Throws:
BeansException
- if theBeanFactory
could not be initialized.- See Also:
-
getBeanFactory
Returns the configured reference to theBeanFactory
.- Returns:
- the configured reference to the
BeanFactory
. - Throws:
IllegalStateException
- if theBeanFactory
reference was not configured.- See Also:
-
requireBeanOfType
Gets a required bean of the providedtype
from theBeanFactory
.- Type Parameters:
T
-parameterized class type
of the bean.- Parameters:
beanType
-type
of the bean.- Returns:
- a required bean of the given
type
from theBeanFactory
. - See Also:
-
getKeyspaceName
Return the name of the keyspace to connect to.- Returns:
- must not be null.
-
getLocalDataCenter
Returns the local data center name used forLoadBalancingPolicy
, defaulting todatacenter1
. Typically required when connecting a Cassandra cluster. Not required when using an Astra connection bundle.- Returns:
- the local data center name. Can be null when using an Astra connection bundle.
-
getSessionName
Returns the session name.- Returns:
- the session name; may be null.
- Since:
- 3.0
-
getCompressionType
Returns theCompressionType
.- Returns:
- the
CompressionType
, may be null.
-
getContactPoints
Returns the Cassandra contact points. Defaults tolocalhost
- Returns:
- the Cassandra contact points
- See Also:
-
getPort
protected int getPort()Returns the Cassandra port. Defaults to9042
.- Returns:
- the Cassandra port
- See Also:
-
getKeyspaceCreations
Returns the list of keyspace creations to be run right after initialization.- Returns:
- the list of keyspace creations, may be empty but never
null
.
-
getKeyspaceDrops
Returns the list of keyspace drops to be run before shutdown.- Returns:
- the list of keyspace drops, may be empty but never
null
.
-
getRequiredSession
protected com.datastax.oss.driver.api.core.CqlSession getRequiredSession()Returns the initializedCqlSession
instance.- Returns:
- the
CqlSession
. - Throws:
IllegalStateException
- if the session factory is not initialized.
-
getRequiredSessionFactory
Returns the initializedCqlSession
instance.- Returns:
- the
CqlSession
. - Throws:
IllegalStateException
- if the session factory is not initialized.
-
getSessionBuilderConfigurer
Returns theSessionBuilderConfigurer
.- Returns:
- the
SessionBuilderConfigurer
; may be null. - Since:
- 1.5
-
getDriverConfigLoaderBuilderConfigurer
Returns theDriverConfigLoaderBuilderConfigurer
. The configuration gets applied after applyingSystem Properties
config overrides and beforethe driver config file
.- Returns:
- the
DriverConfigLoaderBuilderConfigurer
; may be null. - Since:
- 3.1.2
-
getDriverConfigurationResource
Returns theResource
pointing to a driver configuration file. The configuration file is applied after applyingSystem Properties
and the configuration built by this configuration class.- Returns:
- the
Resource
; may be null if none provided. - Since:
- 3.1.2
- See Also:
-
cassandraSession
Creates aCqlSessionFactoryBean
that provides a CassandraCqlSession
.- Returns:
- the
CqlSessionFactoryBean
. - See Also:
-
cqlTemplate
Creates aCqlTemplate
configured withgetRequiredSessionFactory()
.- Returns:
- the
CqlTemplate
. - See Also:
-