Class AbstractSessionConfiguration
java.lang.Object
org.springframework.data.cassandra.config.AbstractSessionConfiguration
- All Implemented Interfaces:
Aware,BeanFactoryAware
- Direct Known Subclasses:
AbstractCassandraConfiguration,AbstractCqlTemplateConfiguration
@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 aCqlSessionFactoryBeanthat provides a CassandraCqlSession.Creates aCqlTemplateconfigured withgetRequiredSessionFactory().protected BeanFactoryReturns the configured reference to theBeanFactory.protected StringDeprecated.protected CompressionTypeReturns theCompressionType.protected StringReturns the Cassandra contact points.protected DriverConfigLoaderBuilderConfigurerReturns theDriverConfigLoaderBuilderConfigurer.protected ResourceReturns theResourcepointing 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 StringReturn the name of the keyspace to connect to.protected StringReturns the local data center name used forLoadBalancingPolicy, defaulting todatacenter1.protected intgetPort()Returns the Cassandra port.protected com.datastax.oss.driver.api.core.CqlSessionReturns the initializedCqlSessioninstance.protected SessionFactoryReturns the initializedCqlSessioninstance.protected SessionBuilderConfigurerReturns theSessionBuilderConfigurer.protected StringReturns the session name.Deprecated.since 3.0; Declare aSessionFactoryInitializerbean instead.Deprecated.since 3.0; Declare aSessionFactoryInitializerbean instead.protected <T> TrequireBeanOfType(Class<T> beanType) Gets a required bean of the providedtypefrom theBeanFactory.voidsetBeanFactory(BeanFactory beanFactory) Configures a reference to theBeanFactory.
-
Constructor Details
-
AbstractSessionConfiguration
public AbstractSessionConfiguration()
-
-
Method Details
-
setBeanFactory
Configures a reference to theBeanFactory.- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- Parameters:
beanFactory- reference to theBeanFactory.- Throws:
BeansException- if theBeanFactorycould not be initialized.- See Also:
-
getBeanFactory
Returns the configured reference to theBeanFactory.- Returns:
- the configured reference to the
BeanFactory. - Throws:
IllegalStateException- if theBeanFactoryreference was not configured.- See Also:
-
requireBeanOfType
Gets a required bean of the providedtypefrom theBeanFactory.- Type Parameters:
T-parameterized class typeof the bean.- Parameters:
beanType-typeof the bean.- Returns:
- a required bean of the given
typefrom theBeanFactory. - See Also:
-
getClusterName
Deprecated.since 3.0, usegetSessionName()instead.Returns thenameof the cluster.- Returns:
- the
cluster name; may be null. - Since:
- 1.5
-
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 initializedCqlSessioninstance.- Returns:
- the
CqlSession. - Throws:
IllegalStateException- if the session factory is not initialized.
-
getRequiredSessionFactory
Returns the initializedCqlSessioninstance.- 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 Propertiesconfig overrides and beforethe driver config file.- Returns:
- the
DriverConfigLoaderBuilderConfigurer; may be null. - Since:
- 3.1.2
-
getDriverConfigurationResource
Returns theResourcepointing to a driver configuration file. The configuration file is applied after applyingSystem Propertiesand the configuration built by this configuration class.- Returns:
- the
Resource; may be null if none provided. - Since:
- 3.1.2
- See Also:
-
getStartupScripts
Deprecated.since 3.0; Declare aSessionFactoryInitializerbean instead.Returns the list of CQL scripts to be run on startup afterKeyspace creationsand after initialization of the System Keyspace. return super.getSessionBuilderConfigurer();- Returns:
- the list of CQL scripts to be run on startup; may be
emptybut never null.
-
getShutdownScripts
Deprecated.since 3.0; Declare aSessionFactoryInitializerbean instead.Returns the list of CQL scripts to be run on shutdown afterKeyspace dropsand right before shutdown of theSystemKeyspace.- Returns:
- the list of CQL scripts to be run on shutdown; may be
emptybut never null.
-
cassandraSession
Creates aCqlSessionFactoryBeanthat provides a CassandraCqlSession.- Returns:
- the
CqlSessionFactoryBean. - See Also:
-
cqlTemplate
Creates aCqlTemplateconfigured withgetRequiredSessionFactory().- Returns:
- the
CqlTemplate. - See Also:
-
getSessionName()instead.