DATACASS-125 : WIP : DocBook
This commit is contained in:
@@ -247,7 +247,7 @@ public class CassandraApp {
|
||||
<para><programlisting>cassandra.contactpoints=10.1.55.80,10.1.55.81
|
||||
cassandra.port=9042
|
||||
cassandra.keyspace=showcase</programlisting>We will use spring to load these
|
||||
properties into the Spring Context in the next two examples. </para>
|
||||
properties into the Spring Context in the next two examples.</para>
|
||||
</section>
|
||||
|
||||
<section id="cassandra-connectors.xmlconfig">
|
||||
@@ -269,32 +269,38 @@ cassandra.keyspace=showcase</programlisting>We will use spring to load these
|
||||
|
||||
<programlisting><?xml version='1.0'?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/cql http://www.springframework.org/schema/cql/spring-cql-1.0.xsd
|
||||
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/cql http://www.springframework.org/schema/cql/spring-cql-1.0.xsd
|
||||
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
|
||||
|
||||
<!-- Loads the properties into the Spring Context and uses them to fill
|
||||
in placeholders in the bean definitions -->
|
||||
<context:property-placeholder location="classpath:cassandra.properties" />
|
||||
|
||||
<!-- Loads the properties into the Spring Context and uses them to fill
|
||||
in placeholders in the bean definitions -->
|
||||
<context:property-placeholder location="classpath:cassandra.properties" />
|
||||
<!-- REQUIRED: The Cassandra Cluster -->
|
||||
<cassandra:cluster contact-points="${cassandra.contactpoints}"
|
||||
port="${cassandra.port}" />
|
||||
|
||||
<!-- REQUIRED: The Cassandra Cluster -->
|
||||
<cassandra:cluster contact-points="${cassandra.contactpoints}" port="${cassandra.port}" />
|
||||
<!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching
|
||||
to a keyspace -->
|
||||
<cassandra:session keyspace-name="${cassandra.keyspace}" />
|
||||
|
||||
<!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace -->
|
||||
<cassandra:session keyspace-name="${cassandra.keyspace}" />
|
||||
<!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter -->
|
||||
<cassandra:mapping />
|
||||
|
||||
<!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
|
||||
<cassandra:converter/>
|
||||
<!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
|
||||
<cassandra:converter />
|
||||
|
||||
<!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra -->
|
||||
<cassandra:template/>
|
||||
<!-- REQUIRED: The Cassandra Template is the building block of all Spring
|
||||
Data Cassandra -->
|
||||
<cassandra:template id="cassandraTemplate" />
|
||||
|
||||
<!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add your base packages to scan here-->
|
||||
<cassandra:repositories base-package="org.spring.cassandra.example.repo" />
|
||||
<!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add
|
||||
your base packages to scan here -->
|
||||
<cassandra:repositories base-package="org.spring.cassandra.example.repo" />
|
||||
|
||||
</beans>
|
||||
</programlisting>
|
||||
@@ -319,7 +325,43 @@ cassandra.keyspace=showcase</programlisting>We will use spring to load these
|
||||
<section id="cassandra-template.instantiating">
|
||||
<title>Instantiating CassandraTemplate</title>
|
||||
|
||||
<para>CassandraTemplate requires a Cassandra Session object.</para>
|
||||
<para><literal>CassandraTemplate</literal> should always be configured
|
||||
as a Spring Bean, although we show an example above where you can
|
||||
instantiate it directly. But for the purposes of this being a Spring
|
||||
module, lets assume we are using the Spring Container.</para>
|
||||
|
||||
<para><literal>CassandraTemplate</literal> is an implementation of
|
||||
<literal>CassandraOperations</literal>. You should always assign your
|
||||
<literal>CassandraTemplate</literal> to its interface definition,
|
||||
<literal>CassandraOperations</literal>.</para>
|
||||
|
||||
<para>There are 2 easy ways to get a
|
||||
<literal>CassandraTemplate</literal>, depending on how you load you
|
||||
Spring Application Context.</para>
|
||||
|
||||
<bridgehead>AutoWiring</bridgehead>
|
||||
|
||||
<programlisting>@Autowired
|
||||
private CassandraOperations cassandraOperations;</programlisting>
|
||||
|
||||
<para>Like all Spring Autowiring, this assumes there is only one bean of
|
||||
type <literal>CassandraOperations</literal> in the
|
||||
<literal>ApplicationContext</literal>. If you have multiple
|
||||
<literal>CassandraTemplate</literal> beans (which will be the case if
|
||||
you are working with multiple keyspaces in the same project), use the
|
||||
<literal>@Qualifier </literal>annotation to designate which bean you
|
||||
want to Autowire.</para>
|
||||
|
||||
<programlisting>@Autowired
|
||||
@Qualifier("myTemplateBeanId")
|
||||
private CassandraOperations cassandraOperations;</programlisting>
|
||||
|
||||
<bridgehead>Bean Lookup with ApplicationContext</bridgehead>
|
||||
|
||||
<para>You can also just lookup the <literal>CassandraTemplate</literal>
|
||||
bean from the <literal>ApplicationContext</literal>.</para>
|
||||
|
||||
<programlisting>CassandraOperations cassandraOperations = applicationContext.getBean("cassandraTemplate", CassandraOperations.class);</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -337,8 +379,6 @@ cassandra.keyspace=showcase</programlisting>We will use spring to load these
|
||||
<para>Cassandra requires that you have at least 1 Partition Key field
|
||||
for a CQL Table. Alternately, you can have one or more Clustering Key
|
||||
fields.</para>
|
||||
|
||||
<para>TODO With Examples</para>
|
||||
</section>
|
||||
|
||||
<section id="cassandra-template.type-mapping">
|
||||
@@ -362,13 +402,10 @@ cassandra.keyspace=showcase</programlisting>We will use spring to load these
|
||||
<section id="cassandra-template.upserts">
|
||||
<title>Upserting rows in a CQL table</title>
|
||||
|
||||
<para>TODO With Examples</para>
|
||||
</section>
|
||||
|
||||
<section id="cassandra-template.find-and-upsert">
|
||||
<title>Finding and Upserting rowa in a CQL table</title>
|
||||
|
||||
<para>TODO With Examples</para>
|
||||
<para>To upsert a row in Cassandra, use the insert logic explained in
|
||||
the previous section. When you insert a row into Cassandra, and there is
|
||||
already a row for that primary key value, the row is overwritten by the
|
||||
data in the new insert.</para>
|
||||
</section>
|
||||
|
||||
<section id="cassandra-template.delete">
|
||||
|
||||
Reference in New Issue
Block a user