public class CassandraCqlSessionFactoryBean extends Object implements FactoryBean<com.datastax.driver.core.Session>, InitializingBean, DisposableBean, PersistenceExceptionTranslator
Session, which is a thread-safe singleton. As such, it is
sufficient to have one Session per application and keyspace.DisposableBean,
FactoryBean,
InitializingBean,
PersistenceExceptionTranslator,
CqlTemplate,
CassandraExceptionTranslator,
Cluster,
Session| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
CassandraCqlSessionFactoryBean() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
destroy() |
protected void |
executeScripts(List<String> scripts)
Executes the given Cassandra CQL scripts.
|
protected com.datastax.driver.core.Cluster |
getCluster()
Returns a reference to the configured Cassandra
Cluster used by this application. |
protected String |
getKeyspaceName()
Gets the name of the Cassandra Keyspace to connect to.
|
com.datastax.driver.core.Session |
getObject() |
Class<? extends com.datastax.driver.core.Session> |
getObjectType() |
protected com.datastax.driver.core.Session |
getSession()
Returns a reference to the connected Cassandra
Session. |
List<String> |
getShutdownScripts()
Returns an unmodifiable list of shutdown scripts.
|
List<String> |
getStartupScripts()
Returns an unmodifiable list of startup scripts.
|
boolean |
isConnected()
Null-safe operation to determine whether the Cassandra
Session is connected or not. |
boolean |
isSingleton() |
void |
setCluster(com.datastax.driver.core.Cluster cluster)
Sets a reference to the Cassandra
Cluster to use. |
void |
setKeyspaceName(String keyspaceName)
Sets the name of the Cassandra Keyspace to connect to.
|
void |
setShutdownScripts(List<String> scripts)
Sets CQL scripts to be executed immediately before the session is shutdown.
|
void |
setStartupScripts(List<String> scripts)
Sets CQL scripts to be executed immediately after the session is connected.
|
DataAccessException |
translateExceptionIfPossible(RuntimeException e) |
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanExceptionpublic com.datastax.driver.core.Session getObject()
getObject in interface FactoryBean<com.datastax.driver.core.Session>public Class<? extends com.datastax.driver.core.Session> getObjectType()
getObjectType in interface FactoryBean<com.datastax.driver.core.Session>public boolean isSingleton()
isSingleton in interface FactoryBean<com.datastax.driver.core.Session>public void destroy()
throws Exception
destroy in interface DisposableBeanExceptionprotected void executeScripts(List<String> scripts)
Session must be connected when this method is called.public DataAccessException translateExceptionIfPossible(RuntimeException e)
translateExceptionIfPossible in interface PersistenceExceptionTranslatorpublic boolean isConnected()
Session is connected or not.Session is connected.Session.isClosed(),
getObject()public void setCluster(com.datastax.driver.core.Cluster cluster)
Cluster to use.cluster - a reference to the Cassandra Cluster used by this application.IllegalArgumentException - if the Cluster reference is null.Cluster,
getCluster()protected com.datastax.driver.core.Cluster getCluster()
Cluster used by this application.Cluster.IllegalStateException - if the reference to the Cluster was not properly initialized.Cluster,
setCluster(Cluster)public void setKeyspaceName(@Nullable String keyspaceName)
keyspaceName - a String indicating the name of the Keyspace in which to connect.getKeyspaceName()@Nullable protected String getKeyspaceName()
setKeyspaceName(String)protected com.datastax.driver.core.Session getSession()
Session.Session.IllegalStateException - if the Cassandra Session was not properly initialized.Sessionpublic void setStartupScripts(@Nullable List<String> scripts)
public List<String> getStartupScripts()
public void setShutdownScripts(@Nullable List<String> scripts)
Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.