@Configuration public abstract class AbstractSessionConfiguration extends Object implements BeanFactoryAware
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.BeanFactoryAware,
Configuration| Constructor and Description |
|---|
AbstractSessionConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
CqlSessionFactoryBean |
cassandraSession()
Creates a
CqlSessionFactoryBean that provides a Cassandra CqlSession. |
CqlTemplate |
cqlTemplate()
Creates a
CqlTemplate configured with getRequiredSessionFactory(). |
protected BeanFactory |
getBeanFactory()
Returns the configured reference to the
BeanFactory. |
protected String |
getClusterName()
Deprecated.
since 3.0, use
getSessionName() instead. |
protected CompressionType |
getCompressionType()
Returns the
CompressionType. |
protected String |
getContactPoints()
Returns the Cassandra contact points.
|
protected DriverConfigLoaderBuilderConfigurer |
getDriverConfigLoaderBuilderConfigurer()
Returns the
DriverConfigLoaderBuilderConfigurer. |
protected Resource |
getDriverConfigurationResource()
Returns the
Resource pointing to a driver configuration file. |
protected List<CreateKeyspaceSpecification> |
getKeyspaceCreations()
Returns the list of keyspace creations to be run right after initialization.
|
protected List<DropKeyspaceSpecification> |
getKeyspaceDrops()
Returns the list of keyspace drops to be run before shutdown.
|
protected abstract String |
getKeyspaceName()
Return the name of the keyspace to connect to.
|
protected String |
getLocalDataCenter()
Returns the local data center name used for
LoadBalancingPolicy, defaulting to datacenter1. |
protected int |
getPort()
Returns the Cassandra port.
|
protected com.datastax.oss.driver.api.core.CqlSession |
getRequiredSession()
Returns the initialized
CqlSession instance. |
protected SessionFactory |
getRequiredSessionFactory()
Returns the initialized
CqlSession instance. |
protected SessionBuilderConfigurer |
getSessionBuilderConfigurer()
Returns the
SessionBuilderConfigurer. |
protected String |
getSessionName()
Returns the session name.
|
protected List<String> |
getShutdownScripts()
Deprecated.
since 3.0; Declare a
SessionFactoryInitializer bean instead. |
protected List<String> |
getStartupScripts()
Deprecated.
since 3.0; Declare a
SessionFactoryInitializer bean instead. |
protected <T> T |
requireBeanOfType(Class<T> beanType)
Gets a required bean of the provided
type from the BeanFactory. |
void |
setBeanFactory(BeanFactory beanFactory)
Configures a reference to the
BeanFactory. |
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
BeanFactory.setBeanFactory in interface BeanFactoryAwarebeanFactory - reference to the BeanFactory.BeansException - if the BeanFactory could not be initialized.BeanFactoryprotected BeanFactory getBeanFactory()
BeanFactory.BeanFactory.IllegalStateException - if the BeanFactory reference was not configured.BeanFactoryprotected <T> T requireBeanOfType(@NonNull Class<T> beanType)
type from the BeanFactory.T - parameterized class type of the bean.beanType - type of the bean.type from the BeanFactory.BeanFactory.getBean(Class),
getBeanFactory()@Nullable @Deprecated protected String getClusterName()
getSessionName() instead.name of the cluster.cluster name; may be null.protected abstract String getKeyspaceName()
@Nullable protected String getLocalDataCenter()
LoadBalancingPolicy, defaulting to datacenter1.
Typically required when connecting a Cassandra cluster. Not required when using an Astra connection bundle.@Nullable protected String getSessionName()
@Nullable protected CompressionType getCompressionType()
CompressionType.CompressionType, may be null.protected String getContactPoints()
localhostCqlSessionFactoryBean.DEFAULT_CONTACT_POINTSprotected int getPort()
9042.CqlSessionFactoryBean.DEFAULT_PORTprotected List<CreateKeyspaceSpecification> getKeyspaceCreations()
null.protected List<DropKeyspaceSpecification> getKeyspaceDrops()
null.protected com.datastax.oss.driver.api.core.CqlSession getRequiredSession()
CqlSession instance.CqlSession.IllegalStateException - if the session factory is not initialized.protected SessionFactory getRequiredSessionFactory()
CqlSession instance.CqlSession.IllegalStateException - if the session factory is not initialized.@Nullable protected SessionBuilderConfigurer getSessionBuilderConfigurer()
SessionBuilderConfigurer.SessionBuilderConfigurer; may be null.@Nullable protected DriverConfigLoaderBuilderConfigurer getDriverConfigLoaderBuilderConfigurer()
DriverConfigLoaderBuilderConfigurer. The configuration gets applied after applying
System Properties config overrides and before
the driver config file.DriverConfigLoaderBuilderConfigurer; may be null.@Nullable protected Resource getDriverConfigurationResource()
Resource pointing to a driver configuration file. The configuration file is applied after
applying System Properties and the configuration built by this configuration class.Resource; may be null if none provided.@Deprecated protected List<String> getStartupScripts()
SessionFactoryInitializer bean instead.Keyspace creations
and after initialization of the System Keyspace.empty
but never null.@Deprecated protected List<String> getShutdownScripts()
SessionFactoryInitializer bean instead.Keyspace drops
and right before shutdown of the System Keyspace.empty
but never null.@Bean public CqlSessionFactoryBean cassandraSession()
CqlSessionFactoryBean that provides a Cassandra CqlSession.CqlSessionFactoryBean.getKeyspaceName(),
getStartupScripts(),
getShutdownScripts()@Bean public CqlTemplate cqlTemplate()
CqlTemplate configured with getRequiredSessionFactory().CqlTemplate.getRequiredSession()Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.