diff --git a/pom.xml b/pom.xml
index 6a52dc867..b6ad3dc88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,11 +27,14 @@
+ UTF-8
+ UTF-8multispring-data-cassandra1.6.2.RELEASE1.2.0.11.0.4-dse
+ 2.16
@@ -64,7 +67,7 @@
Alex Shvida at shvid.com
- Project Lead
+ Project LeadDeveloper-8
@@ -123,10 +126,19 @@
${spring}
+
org.slf4j
- slf4j-api
- 1.7.4
+ log4j-over-slf4j
+ ${slf4j}
+ test
+
+
+
+ org.slf4j
+ jul-to-slf4j
+ ${slf4j}
+ test
@@ -227,7 +239,7 @@
org.apache.maven.pluginsmaven-surefire-plugin
- -Xmx2048m -XX:MaxPermSize=512m
+ -Xmx2048m -XX:MaxPermSize=512mmethods10false
@@ -246,8 +258,10 @@
org.apache.maven.pluginsmaven-failsafe-plugin
+ ${failsafe.version}
- -Xmx2048m -XX:MaxPermSize=512m
+ always
+ -Xmx2048m -XX:MaxPermSize=512mfalse**/test/integration/**/*.java
diff --git a/spring-cassandra/pom.xml b/spring-cassandra/pom.xml
index db65767f3..b3afd4fd1 100644
--- a/spring-cassandra/pom.xml
+++ b/spring-cassandra/pom.xml
@@ -44,6 +44,12 @@
com.datastax.cassandracassandra-driver-core
+
+
+ log4j
+ log4j
+
+ javax.enterprise
@@ -72,6 +78,11 @@
+
+ cglib
+ cglib-nodep
+ test
+ javax.elel-api
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraClusterFactoryBean.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraClusterFactoryBean.java
similarity index 96%
rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraClusterFactoryBean.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraClusterFactoryBean.java
index 5221028cb..ea21b424c 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraClusterFactoryBean.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraClusterFactoryBean.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.core;
+package org.springframework.cassandra.config;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
@@ -21,9 +21,6 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.cassandra.support.CassandraExceptionTranslator;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
-import org.springframework.data.cassandra.config.CompressionType;
-import org.springframework.data.cassandra.config.PoolingOptionsConfig;
-import org.springframework.data.cassandra.config.SocketOptionsConfig;
import org.springframework.util.StringUtils;
import com.datastax.driver.core.AuthProvider;
@@ -40,6 +37,7 @@ import com.datastax.driver.core.policies.RetryPolicy;
* Convenient factory for configuring a Cassandra Cluster.
*
* @author Alex Shvid
+ * @author Matthew T. Adams
*/
public class CassandraClusterFactoryBean implements FactoryBean, InitializingBean, DisposableBean,
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraSessionFactoryBean.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraSessionFactoryBean.java
new file mode 100644
index 000000000..2a5168db7
--- /dev/null
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraSessionFactoryBean.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2011-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.cassandra.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.cassandra.support.CassandraExceptionTranslator;
+import org.springframework.dao.DataAccessException;
+import org.springframework.dao.support.PersistenceExceptionTranslator;
+import org.springframework.util.StringUtils;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+
+/**
+ * Factory for configuring a Cassandra {@link Session}, which is a thread-safe singleton. As such, it is sufficient to
+ * have one {@link Session} per application and keyspace.
+ *
+ * @author Alex Shvid
+ * @author Matthew T. Adams
+ */
+
+public class CassandraSessionFactoryBean implements FactoryBean, InitializingBean, DisposableBean,
+ PersistenceExceptionTranslator {
+
+ private static final Logger log = LoggerFactory.getLogger(CassandraSessionFactoryBean.class);
+
+ public static final String DEFAULT_REPLICATION_STRATEGY = "SimpleStrategy";
+ public static final int DEFAULT_REPLICATION_FACTOR = 1;
+
+ private Cluster cluster;
+ private Session session;
+ private String keyspaceName;
+
+ private final PersistenceExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();
+
+ public Session getObject() {
+ return session;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ public Class extends Session> getObjectType() {
+ return Session.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+ */
+ public boolean isSingleton() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.dao.support.PersistenceExceptionTranslator#translateExceptionIfPossible(java.lang.RuntimeException)
+ */
+ public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
+ return exceptionTranslator.translateExceptionIfPossible(ex);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+
+ if (cluster == null) {
+ throw new IllegalArgumentException("at least one cluster is required");
+ }
+
+ this.session = StringUtils.hasText(this.keyspaceName) ? cluster.connect(keyspaceName) : cluster.connect();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.beans.factory.DisposableBean#destroy()
+ */
+ public void destroy() throws Exception {
+ this.session.shutdown();
+ }
+
+ public void setKeyspaceName(String keyspaceName) {
+ this.keyspaceName = keyspaceName;
+ }
+
+ public void setCluster(Cluster cluster) {
+ this.cluster = cluster;
+ }
+}
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraTemplateFactoryBean.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraTemplateFactoryBean.java
new file mode 100644
index 000000000..660ac9c85
--- /dev/null
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CassandraTemplateFactoryBean.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.cassandra.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.cassandra.core.CassandraOperations;
+import org.springframework.cassandra.core.CassandraTemplate;
+
+import com.datastax.driver.core.Session;
+
+/**
+ * Factory for configuring a {@link CassandraTemplate}.
+ *
+ * @author Matthew T. Adams
+ */
+public class CassandraTemplateFactoryBean implements FactoryBean, InitializingBean {
+
+ private static final Logger log = LoggerFactory.getLogger(CassandraTemplateFactoryBean.class);
+
+ private CassandraTemplate template;
+ private Session session;
+
+ public CassandraOperations getObject() {
+ return template;
+ }
+
+ public Class extends CassandraOperations> getObjectType() {
+ return CassandraOperations.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+
+ if (session == null) {
+ throw new IllegalStateException("session is required");
+ }
+
+ this.template = new CassandraTemplate(session);
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+}
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CompressionType.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CompressionType.java
similarity index 93%
rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CompressionType.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/CompressionType.java
index c74c36676..4e9248ada 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CompressionType.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/CompressionType.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.config;
+package org.springframework.cassandra.config;
/**
* Simple enumeration for the various compression types.
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/config/KeyspaceAttributes.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/KeyspaceAttributes.java
new file mode 100644
index 000000000..052315434
--- /dev/null
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/KeyspaceAttributes.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.cassandra.config;
+
+/**
+ * Keyspace attributes.
+ *
+ * @author Alex Shvid
+ * @author Matthew T. Adams
+ */
+public class KeyspaceAttributes {
+
+ public static final String DEFAULT_REPLICATION_STRATEGY = "SimpleStrategy";
+ public static final int DEFAULT_REPLICATION_FACTOR = 1;
+ public static final boolean DEFAULT_DURABLE_WRITES = true;
+
+ private String replicationStrategy = DEFAULT_REPLICATION_STRATEGY;
+ private int replicationFactor = DEFAULT_REPLICATION_FACTOR;
+ private boolean durableWrites = DEFAULT_DURABLE_WRITES;
+
+ public String getReplicationStrategy() {
+ return replicationStrategy;
+ }
+
+ public void setReplicationStrategy(String replicationStrategy) {
+ this.replicationStrategy = replicationStrategy;
+ }
+
+ public int getReplicationFactor() {
+ return replicationFactor;
+ }
+
+ public void setReplicationFactor(int replicationFactor) {
+ this.replicationFactor = replicationFactor;
+ }
+
+ public boolean isDurableWrites() {
+ return durableWrites;
+ }
+
+ public void setDurableWrites(boolean durableWrites) {
+ this.durableWrites = durableWrites;
+ }
+}
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/PoolingOptionsConfig.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/PoolingOptionsConfig.java
similarity index 94%
rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/PoolingOptionsConfig.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/PoolingOptionsConfig.java
index 4ba96539e..e982e217d 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/PoolingOptionsConfig.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/PoolingOptionsConfig.java
@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.config;
+package org.springframework.cassandra.config;
/**
- * Pooling options POJO. Can be remote or local.
+ * Pooling options.
*
* @author Alex Shvid
+ * @author Matthew T. Adams
*/
public class PoolingOptionsConfig {
@@ -58,5 +59,4 @@ public class PoolingOptionsConfig {
public void setMaxConnections(Integer maxConnections) {
this.maxConnections = maxConnections;
}
-
}
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/SocketOptionsConfig.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/SocketOptionsConfig.java
similarity index 95%
rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/SocketOptionsConfig.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/SocketOptionsConfig.java
index 1e72c7742..562377415 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/SocketOptionsConfig.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/SocketOptionsConfig.java
@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.config;
+package org.springframework.cassandra.config;
/**
- * Socket options POJO. Uses to configure Netty.
+ * Socket options.
*
* @author Alex Shvid
+ * @author Matthew T. Adams
*/
public class SocketOptionsConfig {
@@ -85,5 +86,4 @@ public class SocketOptionsConfig {
public void setSendBufferSize(Integer sendBufferSize) {
this.sendBufferSize = sendBufferSize;
}
-
}
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/config/TableAttributes.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/TableAttributes.java
new file mode 100644
index 000000000..ce6d26137
--- /dev/null
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/TableAttributes.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.cassandra.config;
+
+/**
+ * Table attributes are used for manipulation around table at the startup (create/update/validate).
+ *
+ * @author Alex Shvid
+ */
+public class TableAttributes {
+
+ private String entity;
+ private String name;
+
+ public String getEntity() {
+ return entity;
+ }
+
+ public void setEntity(String entity) {
+ this.entity = entity;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "TableAttributes [entity=" + entity + "]";
+ }
+
+}
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/config/java/AbstractCassandraConfiguration.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/java/AbstractCassandraConfiguration.java
new file mode 100644
index 000000000..955256a70
--- /dev/null
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/java/AbstractCassandraConfiguration.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.cassandra.config.java;
+
+import org.springframework.cassandra.core.CassandraOperations;
+import org.springframework.cassandra.core.CassandraTemplate;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.util.StringUtils;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+
+/**
+ * Base class for Spring Cassandra configuration using JavaConfig.
+ *
+ * @author Alex Shvid
+ * @author Matthew T. Adams
+ */
+@Configuration
+public abstract class AbstractCassandraConfiguration {
+
+ /**
+ * The name of the keyspace to connect to. If {@literal null} or empty, then the system keyspace will be used.
+ */
+ protected abstract String getKeyspaceName();
+
+ /**
+ * The {@link Cluster} instance to connect to. Must not be null.
+ */
+ @Bean
+ public abstract Cluster cluster();
+
+ /**
+ * Creates a {@link Session} using the {@link Cluster} instance configured in {@link #cluster()}.
+ *
+ * @see #cluster()
+ */
+ @Bean
+ public Session session() {
+ String keyspaceName = getKeyspaceName();
+ return StringUtils.hasText(keyspaceName) ? cluster().connect(keyspaceName) : cluster().connect();
+ }
+
+ /**
+ * A {@link CassandraTemplate} created from the {@link Session} returned by {@link #session()}.
+ */
+ @Bean
+ public CassandraOperations template() {
+ return new CassandraTemplate(session());
+ }
+}
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanNames.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/BeanNames.java
similarity index 86%
rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanNames.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/BeanNames.java
index 762b206fe..07f3537dd 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanNames.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/BeanNames.java
@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.config;
+package org.springframework.cassandra.config.xml;
/**
* @author Alex Shvid
* @author David Webb
+ * @author Matthew T. Adams
*/
public final class BeanNames {
@@ -27,5 +28,5 @@ public final class BeanNames {
public static final String CASSANDRA_CLUSTER = "cassandra-cluster";
public static final String CASSANDRA_KEYSPACE = "cassandra-keyspace";
public static final String CASSANDRA_SESSION = "cassandra-session";
-
+ public static final String CASSANDRA_TEMPLATE = "cassandra-template";
}
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraClusterParser.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraClusterParser.java
similarity index 63%
rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraClusterParser.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraClusterParser.java
index 1718a283f..e454049c0 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraClusterParser.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraClusterParser.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.config;
+package org.springframework.cassandra.config.xml;
import java.util.List;
@@ -23,8 +23,10 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.data.cassandra.core.CassandraClusterFactoryBean;
-import org.springframework.data.config.ParsingUtils;
+import org.springframework.cassandra.config.CassandraClusterFactoryBean;
+import org.springframework.cassandra.config.CompressionType;
+import org.springframework.cassandra.config.PoolingOptionsConfig;
+import org.springframework.cassandra.config.SocketOptionsConfig;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
@@ -33,6 +35,7 @@ import org.w3c.dom.Element;
* Parser for <cluster;gt; definitions.
*
* @author Alex Shvid
+ * @author Matthew T. Adams
*/
public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser {
@@ -72,15 +75,14 @@ public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser {
builder.addPropertyValue("compressionType", CompressionType.valueOf(compression));
}
- postProcess(builder, element);
+ parseChildElements(builder, element);
}
- @Override
- protected void postProcess(BeanDefinitionBuilder builder, Element element) {
- List subElements = DomUtils.getChildElements(element);
+ protected void parseChildElements(BeanDefinitionBuilder builder, Element element) {
+ List elements = DomUtils.getChildElements(element);
// parse nested elements
- for (Element subElement : subElements) {
+ for (Element subElement : elements) {
String name = subElement.getLocalName();
if ("local-pooling-options".equals(name)) {
@@ -95,24 +97,28 @@ public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser {
}
private BeanDefinition parsePoolingOptions(Element element) {
- BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(PoolingOptionsConfig.class);
- ParsingUtils.setPropertyValue(defBuilder, element, "min-simultaneous-requests", "minSimultaneousRequests");
- ParsingUtils.setPropertyValue(defBuilder, element, "max-simultaneous-requests", "maxSimultaneousRequests");
- ParsingUtils.setPropertyValue(defBuilder, element, "core-connections", "coreConnections");
- ParsingUtils.setPropertyValue(defBuilder, element, "max-connections", "maxConnections");
- return defBuilder.getBeanDefinition();
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(PoolingOptionsConfig.class);
+
+ ParsingUtils.setPropertyValue(builder, element, "min-simultaneous-requests", "minSimultaneousRequests");
+ ParsingUtils.setPropertyValue(builder, element, "max-simultaneous-requests", "maxSimultaneousRequests");
+ ParsingUtils.setPropertyValue(builder, element, "core-connections", "coreConnections");
+ ParsingUtils.setPropertyValue(builder, element, "max-connections", "maxConnections");
+
+ return builder.getBeanDefinition();
}
private BeanDefinition parseSocketOptions(Element element) {
- BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(SocketOptionsConfig.class);
- ParsingUtils.setPropertyValue(defBuilder, element, "connect-timeout-mls", "connectTimeoutMls");
- ParsingUtils.setPropertyValue(defBuilder, element, "keep-alive", "keepAlive");
- ParsingUtils.setPropertyValue(defBuilder, element, "reuse-address", "reuseAddress");
- ParsingUtils.setPropertyValue(defBuilder, element, "so-linger", "soLinger");
- ParsingUtils.setPropertyValue(defBuilder, element, "tcp-no-delay", "tcpNoDelay");
- ParsingUtils.setPropertyValue(defBuilder, element, "receive-buffer-size", "receiveBufferSize");
- ParsingUtils.setPropertyValue(defBuilder, element, "send-buffer-size", "sendBufferSize");
- return defBuilder.getBeanDefinition();
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(SocketOptionsConfig.class);
+
+ ParsingUtils.setPropertyValue(builder, element, "connect-timeout-mls", "connectTimeoutMls");
+ ParsingUtils.setPropertyValue(builder, element, "keep-alive", "keepAlive");
+ ParsingUtils.setPropertyValue(builder, element, "reuse-address", "reuseAddress");
+ ParsingUtils.setPropertyValue(builder, element, "so-linger", "soLinger");
+ ParsingUtils.setPropertyValue(builder, element, "tcp-no-delay", "tcpNoDelay");
+ ParsingUtils.setPropertyValue(builder, element, "receive-buffer-size", "receiveBufferSize");
+ ParsingUtils.setPropertyValue(builder, element, "send-buffer-size", "sendBufferSize");
+
+ return builder.getBeanDefinition();
}
}
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/CqlProvider.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraNamespaceHandler.java
similarity index 54%
rename from spring-cassandra/src/main/java/org/springframework/cassandra/core/CqlProvider.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraNamespaceHandler.java
index 7b0ddd59d..f09b3071c 100644
--- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/CqlProvider.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraNamespaceHandler.java
@@ -13,14 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.core;
+package org.springframework.cassandra.config.xml;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
- * @author David Webb
+ * Namespace handler for <cassandra> elements.
*
+ * @author Alex Shvid
+ * @author Matthew T. Adams
*/
-public interface CqlProvider {
- String getCql();
+public class CassandraNamespaceHandler extends NamespaceHandlerSupport {
+ public void init() {
+
+ registerBeanDefinitionParser("cluster", new CassandraClusterParser());
+ registerBeanDefinitionParser("session", new CassandraSessionParser());
+ registerBeanDefinitionParser("template", new CassandraTemplateParser());
+ }
}
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraSessionParser.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraSessionParser.java
similarity index 75%
rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraSessionParser.java
rename to spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraSessionParser.java
index f99cfb5bf..7b8c05d92 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraSessionParser.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraSessionParser.java
@@ -13,28 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.config;
+package org.springframework.cassandra.config.xml;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.cassandra.core.SessionFactoryBean;
+import org.springframework.cassandra.config.CassandraSessionFactoryBean;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
/**
- * Parser for <session;gt; definitions.
+ * Parser for <session> definitions.
*
* @author David Webb
+ * @author Matthew T. Adams
*/
public class CassandraSessionParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected Class> getBeanClass(Element element) {
- return SessionFactoryBean.class;
+ return CassandraSessionFactoryBean.class;
}
/*
@@ -52,18 +53,16 @@ public class CassandraSessionParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
- String keyspaceRef = element.getAttribute("cassandra-keyspace-ref");
- if (!StringUtils.hasText(keyspaceRef)) {
- keyspaceRef = BeanNames.CASSANDRA_KEYSPACE;
+ String keyspaceName = element.getAttribute("keyspace-name");
+ if (!StringUtils.hasText(keyspaceName)) {
+ keyspaceName = null;
}
- builder.addPropertyReference("keyspace", keyspaceRef);
+ builder.addPropertyValue("keyspaceName", keyspaceName);
- postProcess(builder, element);
+ String clusterRef = element.getAttribute("cluster-ref");
+ if (!StringUtils.hasText(clusterRef)) {
+ clusterRef = BeanNames.CASSANDRA_CLUSTER;
+ }
+ builder.addPropertyReference("cluster", clusterRef);
}
-
- @Override
- protected void postProcess(BeanDefinitionBuilder builder, Element element) {
-
- }
-
}
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraTemplateParser.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraTemplateParser.java
new file mode 100644
index 000000000..c796ec9b2
--- /dev/null
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/CassandraTemplateParser.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.cassandra.config.xml;
+
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.cassandra.config.CassandraTemplateFactoryBean;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for <template> definitions.
+ *
+ * @author David Webb
+ * @author Matthew T. Adams
+ */
+
+public class CassandraTemplateParser extends AbstractSimpleBeanDefinitionParser {
+
+ @Override
+ protected Class> getBeanClass(Element element) {
+ return CassandraTemplateFactoryBean.class;
+ }
+
+ @Override
+ protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
+ throws BeanDefinitionStoreException {
+
+ String id = super.resolveId(element, definition, parserContext);
+ return StringUtils.hasText(id) ? id : BeanNames.CASSANDRA_TEMPLATE;
+ }
+
+ @Override
+ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+
+ String sessionRef = element.getAttribute("session-ref");
+ if (!StringUtils.hasText(sessionRef)) {
+ sessionRef = BeanNames.CASSANDRA_SESSION;
+ }
+ builder.addPropertyReference("session", sessionRef);
+ }
+}
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/ParsingUtils.java b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/ParsingUtils.java
new file mode 100644
index 000000000..826c26e3c
--- /dev/null
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/config/xml/ParsingUtils.java
@@ -0,0 +1,33 @@
+package org.springframework.cassandra.config.xml;
+
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
+
+public class ParsingUtils {
+
+ /**
+ * Configures a property value for the given property name reading the attribute of the given name from the given
+ * {@link Element} if the attribute is configured.
+ *
+ * @param builder must not be {@literal null}.
+ * @param element must not be {@literal null}.
+ * @param attrName must not be {@literal null} or empty.
+ * @param propertyName must not be {@literal null} or empty.
+ */
+ public static void setPropertyValue(BeanDefinitionBuilder builder, Element element, String attrName,
+ String propertyName) {
+
+ Assert.notNull(builder, "BeanDefinitionBuilder must not be null!");
+ Assert.notNull(element, "Element must not be null!");
+ Assert.hasText(attrName, "Attribute name must not be null!");
+ Assert.hasText(propertyName, "Property name must not be null!");
+
+ String attr = element.getAttribute(attrName);
+
+ if (StringUtils.hasText(attr)) {
+ builder.addPropertyValue(propertyName, attr);
+ }
+ }
+}
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraOperations.java b/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraOperations.java
index 02d8d9ec6..31bee51a9 100644
--- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraOperations.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraOperations.java
@@ -66,19 +66,6 @@ public interface CassandraOperations {
*/
T query(final String cql, ResultSetExtractor rse) throws DataAccessException;
- /**
- * Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
- *
- * @param cql The Query
- * @param rse The implementation for extracting the ResultSet
- * @param optionsByName Query Options Map
- *
- * @return
- * @throws DataAccessException
- */
- T query(final String cql, ResultSetExtractor rse, final Map optionsByName)
- throws DataAccessException;
-
/**
* Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
*
@@ -101,18 +88,6 @@ public interface CassandraOperations {
*/
T queryAsynchronously(final String cql, ResultSetFutureExtractor rse) throws DataAccessException;
- /**
- * Executes the provided CQL Query asynchronously, and extracts the results with the ResultSetFutureExtractor
- *
- * @param cql The Query
- * @param rse The implementation for extracting the future results
- * @param optionsByName Query Options Map
- * @return
- * @throws DataAccessException
- */
- T queryAsynchronously(final String cql, ResultSetFutureExtractor rse, final Map optionsByName)
- throws DataAccessException;
-
/**
* Executes the provided CQL Query asynchronously, and extracts the results with the ResultSetFutureExtractor
*
@@ -134,17 +109,6 @@ public interface CassandraOperations {
*/
void query(final String cql, RowCallbackHandler rch) throws DataAccessException;
- /**
- * Executes the provided CQL Query, and then processes the results with the RowCallbackHandler.
- *
- * @param cql The Query
- * @param rch The implementation for processing the rows returned.
- * @param options Query Options Map
- * @throws DataAccessException
- */
- void query(final String cql, RowCallbackHandler rch, final Map optionsByName)
- throws DataAccessException;
-
/**
* Executes the provided CQL Query, and then processes the results with the RowCallbackHandler.
*
@@ -176,18 +140,6 @@ public interface CassandraOperations {
*/
List query(final String cql, RowMapper rowMapper) throws DataAccessException;
- /**
- * Executes the provided CQL Query, and maps all Rows returned with the supplied RowMapper.
- *
- * @param cql The Query
- * @param rowMapper The implementation for mapping all rows
- * @param optionsByName Query Options Map
- * @return List of processed by the RowMapper
- * @throws DataAccessException
- */
- List query(final String cql, RowMapper rowMapper, final Map optionsByName)
- throws DataAccessException;
-
/**
* Executes the provided CQL Query, and maps all Rows returned with the supplied RowMapper.
*
@@ -363,9 +315,6 @@ public interface CassandraOperations {
*/
T query(final String cql, PreparedStatementBinder psb, ResultSetExtractor rse) throws DataAccessException;
- T query(final String cql, PreparedStatementBinder psb, ResultSetExtractor rse,
- final Map optionsByName) throws DataAccessException;
-
T query(final String cql, PreparedStatementBinder psb, ResultSetExtractor rse, final QueryOptions options)
throws DataAccessException;
@@ -381,20 +330,6 @@ public interface CassandraOperations {
*/
void query(final String cql, PreparedStatementBinder psb, RowCallbackHandler rch) throws DataAccessException;
- /**
- * Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
- * bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
- * processed with the RowCallbackHandler implementation provided and nothing is returned.
- *
- * @param cql The Query to Prepare
- * @param psb The Binding implementation
- * @param rch The RowCallbackHandler for processing the ResultSet
- * @param optionsByName The Query Options Map
- * @throws DataAccessException
- */
- void query(final String cql, PreparedStatementBinder psb, RowCallbackHandler rch,
- final Map optionsByName) throws DataAccessException;
-
/**
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
@@ -423,22 +358,6 @@ public interface CassandraOperations {
*/
List query(final String cql, PreparedStatementBinder psb, RowMapper rowMapper) throws DataAccessException;
- /**
- * Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
- * bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
- * processed with the RowMapper implementation provided and a List is returned with elements of Type for each Row
- * returned.
- *
- * @param cql The Query to Prepare
- * @param psb The Binding implementation
- * @param rowMapper The implementation for Mapping a Row to Type
- * @param optionsByName The Query Options Map
- * @return List of for each Row returned from the Query.
- * @throws DataAccessException
- */
- List query(final String cql, PreparedStatementBinder psb, RowMapper rowMapper,
- final Map optionsByName) throws DataAccessException;
-
/**
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
@@ -467,20 +386,6 @@ public interface CassandraOperations {
*/
T query(PreparedStatementCreator psc, ResultSetExtractor rse) throws DataAccessException;
- /**
- * Uses the provided PreparedStatementCreator to prepare a new Session call. This can only be used for CQL
- * Statements that do not have data binding. The results of the PreparedStatement are processed with
- * ResultSetExtractor implementation provided by the Application Code.
- *
- * @param psc The implementation to create the PreparedStatement
- * @param rse Implementation for extracting from the ResultSet
- * @param optionsByName The Query Options Map
- * @return Type which is the output of the ResultSetExtractor
- * @throws DataAccessException
- */
- T query(PreparedStatementCreator psc, ResultSetExtractor rse, final Map optionsByName)
- throws DataAccessException;
-
/**
* Uses the provided PreparedStatementCreator to prepare a new Session call. This can only be used for CQL
* Statements that do not have data binding. The results of the PreparedStatement are processed with
@@ -506,19 +411,6 @@ public interface CassandraOperations {
*/
void query(PreparedStatementCreator psc, RowCallbackHandler rch) throws DataAccessException;
- /**
- * Uses the provided PreparedStatementCreator to prepare a new Session call. This can only be used for CQL
- * Statements that do not have data binding. The results of the PreparedStatement are processed with
- * RowCallbackHandler and nothing is returned.
- *
- * @param psc The implementation to create the PreparedStatement
- * @param rch The implementation to process Results
- * @param optionsByName The Query Options Map
- * @throws DataAccessException
- */
- void query(PreparedStatementCreator psc, RowCallbackHandler rch, final Map optionsByName)
- throws DataAccessException;
-
/**
* Uses the provided PreparedStatementCreator to prepare a new Session call. This can only be used for CQL
* Statements that do not have data binding. The results of the PreparedStatement are processed with
@@ -544,20 +436,6 @@ public interface CassandraOperations {
*/
List query(PreparedStatementCreator psc, RowMapper rowMapper) throws DataAccessException;
- /**
- * Uses the provided PreparedStatementCreator to prepare a new Session call. This can only be used for CQL
- * Statements that do not have data binding. The results of the PreparedStatement are processed with RowMapper
- * implementation provided and a List is returned with elements of Type for each Row returned.
- *
- * @param psc The implementation to create the PreparedStatement
- * @param rowMapper The implementation for mapping each Row returned.
- * @param optionsByName The Query Options Map
- * @return List of Type mapped from each Row in the Results
- * @throws DataAccessException
- */
- List query(PreparedStatementCreator psc, RowMapper rowMapper, final Map optionsByName)
- throws DataAccessException;
-
/**
* Uses the provided PreparedStatementCreator to prepare a new Session call. This can only be used for CQL
* Statements that do not have data binding. The results of the PreparedStatement are processed with RowMapper
@@ -572,21 +450,6 @@ public interface CassandraOperations {
List query(PreparedStatementCreator psc, RowMapper rowMapper, final QueryOptions options)
throws DataAccessException;
- /**
- * Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
- * PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
- * ResultSetExtractor implementation provided by the Application Code.
- *
- * @param psc The implementation to create the PreparedStatement
- * @param psb The implementation to bind variables to values
- * @param rse Implementation for extracting from the ResultSet
- * @param optionsByName The Query Options Map
- * @return Type which is the output of the ResultSetExtractor
- * @throws DataAccessException
- */
- T query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final ResultSetExtractor rse,
- final Map optionsByName) throws DataAccessException;
-
/**
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
@@ -616,21 +479,6 @@ public interface CassandraOperations {
T query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final ResultSetExtractor rse)
throws DataAccessException;
- /**
- * Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
- * PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
- * RowCallbackHandler and nothing is returned.
- *
- * @param psc The implementation to create the PreparedStatement
- * @param psb The implementation to bind variables to values
- * @param rch The implementation to process Results
- * @param optionsByName The Query Options Map
- * @return Type which is the output of the ResultSetExtractor
- * @throws DataAccessException
- */
- void query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowCallbackHandler rch,
- final Map optionsByName) throws DataAccessException;
-
/**
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
@@ -660,21 +508,6 @@ public interface CassandraOperations {
void query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowCallbackHandler rch)
throws DataAccessException;
- /**
- * Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
- * PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
- * RowMapper implementation provided and a List is returned with elements of Type for each Row returned.
- *
- * @param psc The implementation to create the PreparedStatement
- * @param psb The implementation to bind variables to values
- * @param rowMapper The implementation for mapping each Row returned.
- * @param optionsByName The Query Options Map
- * @return Type which is the output of the ResultSetExtractor
- * @throws DataAccessException
- */
- List query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowMapper rowMapper,
- final Map optionsByName) throws DataAccessException;
-
/**
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
@@ -729,21 +562,6 @@ public interface CassandraOperations {
*/
Session getSession();
- /**
- * This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
- * all row values are bound to the single PreparedStatement and executed against the Session.
- *
- *
- * This is used internally by the other ingest() methods, but can be used if you want to write your own RowIterator.
- * The Object[] length returned by the next() implementation must match the number of bind variables in the CQL.
- *
- *
- * @param cql The CQL
- * @param rowIterator Implementation to provide the Object[] to be bound to the CQL.
- * @param optionsByName The Query Options Map
- */
- void ingest(String cql, RowIterator rowIterator, Map optionsByName);
-
/**
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
* all row values are bound to the single PreparedStatement and executed against the Session.
@@ -773,20 +591,6 @@ public interface CassandraOperations {
*/
void ingest(String cql, RowIterator rowIterator);
- /**
- * This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
- * all row values are bound to the single PreparedStatement and executed against the Session.
- *
- *
- * The List> length must match the number of bind variables in the CQL.
- *
- *
- * @param cql The CQL
- * @param rows List of List> with data to bind to the CQL.
- * @param optionsByName The Query Options Map
- */
- void ingest(String cql, List> rows, Map optionsByName);
-
/**
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
* all row values are bound to the single PreparedStatement and executed against the Session.
@@ -814,20 +618,6 @@ public interface CassandraOperations {
*/
void ingest(String cql, List> rows);
- /**
- * This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
- * all row values are bound to the single PreparedStatement and executed against the Session.
- *
- *
- * The Object[] length of the nested array must match the number of bind variables in the CQL.
- *
- *
- * @param cql The CQL
- * @param rows Object array of Object array of values to bind to the CQL.
- * @param optionsByName The Query Options Map
- */
- void ingest(String cql, Object[][] rows, Map optionsByName);
-
/**
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
* all row values are bound to the single PreparedStatement and executed against the Session.
diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraTemplate.java b/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraTemplate.java
index 026f7ff4f..98fb7203a 100644
--- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraTemplate.java
+++ b/spring-cassandra/src/main/java/org/springframework/cassandra/core/CassandraTemplate.java
@@ -17,8 +17,8 @@ package org.springframework.cassandra.core;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -30,7 +30,6 @@ import org.springframework.util.Assert;
import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.ColumnDefinitions.Definition;
-import com.datastax.driver.core.DataType;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;
import com.datastax.driver.core.PreparedStatement;
@@ -91,33 +90,23 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
*/
@Override
public void execute(final String cql) throws DataAccessException {
- doExecute(cql, Collections. emptyMap());
- }
-
- /* (non-Javadoc)
- * @see org.springframework.cassandra.core.CassandraOperations#queryAsynchronously(java.lang.String, org.springframework.cassandra.core.ResultSetFutureExtractor, java.util.Map)
- */
- @Override
- public T queryAsynchronously(final String cql, ResultSetFutureExtractor rse,
- final Map optionsByName) throws DataAccessException {
- return rse.extractData(execute(new SessionCallback() {
- @Override
- public ResultSetFuture doInSession(Session s) throws DataAccessException {
- Statement statement = new SimpleStatement(cql);
- addQueryOptions(statement, optionsByName);
- return s.executeAsync(statement);
- }
- }));
+ doExecute(cql, null);
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.CassandraOperations#queryAsynchronously(java.lang.String, org.springframework.cassandra.core.ResultSetFutureExtractor, org.springframework.cassandra.core.QueryOptions)
*/
@Override
- public T queryAsynchronously(String cql, ResultSetFutureExtractor rse, QueryOptions options)
+ public T queryAsynchronously(final String cql, ResultSetFutureExtractor rse, final QueryOptions options)
throws DataAccessException {
- Assert.notNull(options);
- return queryAsynchronously(cql, rse, options.toMap());
+ return rse.extractData(execute(new SessionCallback() {
+ @Override
+ public ResultSetFuture doInSession(Session s) throws DataAccessException {
+ Statement statement = new SimpleStatement(cql);
+ addQueryOptions(statement, options);
+ return s.executeAsync(statement);
+ }
+ }));
}
/* (non-Javadoc)
@@ -125,18 +114,7 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
*/
@Override
public T queryAsynchronously(final String cql, ResultSetFutureExtractor rse) throws DataAccessException {
- return queryAsynchronously(cql, rse, Collections. emptyMap());
- }
-
- /* (non-Javadoc)
- * @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.ResultSetExtractor)
- */
- public T query(String cql, ResultSetExtractor rse, Map optionsByName)
- throws DataAccessException {
- Assert.notNull(cql);
- Assert.notNull(optionsByName);
- ResultSet rs = doExecute(cql, optionsByName);
- return rse.extractData(rs);
+ return queryAsynchronously(cql, rse, null);
}
/* (non-Javadoc)
@@ -144,7 +122,7 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
*/
@Override
public T query(String cql, ResultSetExtractor rse) throws DataAccessException {
- return query(cql, rse, Collections. emptyMap());
+ return query(cql, rse, null);
}
/* (non-Javadoc)
@@ -152,16 +130,9 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
*/
@Override
public T query(String cql, ResultSetExtractor rse, QueryOptions options) throws DataAccessException {
- Assert.notNull(options);
- return query(cql, rse, options.toMap());
- }
-
- /* (non-Javadoc)
- * @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowCallbackHandler, java.util.Map)
- */
- @Override
- public void query(String cql, RowCallbackHandler rch, Map optionsByName) throws DataAccessException {
- process(doExecute(cql, optionsByName), rch);
+ Assert.notNull(cql);
+ ResultSet rs = doExecute(cql, options);
+ return rse.extractData(rs);
}
/* (non-Javadoc)
@@ -169,25 +140,14 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
*/
@Override
public void query(String cql, RowCallbackHandler rch, QueryOptions options) throws DataAccessException {
- Assert.notNull(options);
- query(cql, rch, options.toMap());
+ process(doExecute(cql, options), rch);
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowCallbackHandler)
*/
public void query(String cql, RowCallbackHandler rch) throws DataAccessException {
- query(cql, rch, Collections. emptyMap());
- }
-
- /* (non-Javadoc)
- * @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowMapper, java.util.Map)
- */
- @Override
- public List query(String cql, RowMapper rowMapper, Map optionsByName)
- throws DataAccessException {
- Assert.notNull(optionsByName);
- return process(doExecute(cql, optionsByName), rowMapper);
+ query(cql, rch, null);
}
/* (non-Javadoc)
@@ -195,50 +155,49 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
*/
@Override
public List query(String cql, RowMapper rowMapper, QueryOptions options) throws DataAccessException {
- Assert.notNull(options);
- return query(cql, rowMapper, options.toMap());
+ return process(doExecute(cql, options), rowMapper);
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowMapper)
*/
public List query(String cql, RowMapper rowMapper) throws DataAccessException {
- return query(cql, rowMapper, Collections. emptyMap());
+ return query(cql, rowMapper, null);
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.CassandraOperations#queryForList(java.lang.String)
*/
public List