added SGF namespace declaration chapter
This commit is contained in:
costin
2010-09-15 21:26:51 +03:00
parent 1d422f5d8f
commit f43154bf1e

View File

@@ -12,8 +12,102 @@
classes that enable the configuration of distributed caches or regions to
support a variety of scenarios with minimal effort.</para>
<section id="bootstrap:namespace">
<title>Using the Spring GemFire Namespace</title>
<para>To simplify configuration, SGF provides a dedicated namespace for most of its components. However, one can opt to configure the beans
directly through the usual &lt;bean&gt; definition. For more information about XML Schema-based configuration in Spring, see
<ulink url="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/xsd-config.html">this</ulink> appendix in the
Spring Framework reference documentation.</para>
<para>To use the SGF namespace, one just needs to import it inside the configuration:</para>
<programlistingco>
<areaspec>
<area id="gfe#ns#prefix" coords="4 11"/>
<area id="gfe#ns#uri" coords="4 58"/>
<area id="gfe#ns#uri#loc" coords="7 119"/>
<area id="gfe#ns#example" coords="10 9"/>
</areaspec>
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
<bean id ... >
<gfe:cache ...>
</beans>]]>
</programlisting>
<calloutlist>
<callout arearefs="gfe#ns#prefix">
<para>Spring GemFire namespace prefix. Any name can do but through out the reference documentation, the <literal>gfe</literal> will be used.</para>
</callout>
<callout arearefs="gfe#ns#uri">
<para>The namespace URI.</para>
</callout>
<callout arearefs="gfe#ns#uri#loc">
<para>The namespace URI location. Note that even though the location points to an external address (which exists and is valid), Spring will resolve
the schema locally as it is included in the Spring GemFire library.</para>
</callout>
<callout arearefs="gfe#ns#example">
<para>Declaration example for the GemFire namespace. Notice the prefix usage.</para>
</callout>
</calloutlist>
</programlistingco>
<para>Once declared, the namespace elements can be declared simply by appending the aforementioned prefix. Note that is possible to change the default namespace,
for example from <literal>&lt;beans&gt;</literal> to <literal>&lt;gfe&gt;</literal>. This is useful for configuration composed mainly of GemFire components as
it avoids declaring the prefix. To achieve this, simply swap the namespace prefix declaration above:</para>
<programlistingco>
<areaspec>
<area id="gfe#default-ns#prefix" coords="2 64"/>
<area id="gfe#default-ns#beans-prefix" coords="3 64"/>
<area id="gfe#default-ns#beans-example" coords="9 64"/>
<area id="gfe#default-ns#gfe-example" coords="11 64"/>
</areaspec>
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/gemfire"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
<beans:bean id ... >
<cache ...>
</beans>]]>
</programlisting>
<calloutlist>
<callout arearefs="gfe#default-ns#prefix">
<para>The default namespace declaration for this XML file points to the Spring GemFire namespace.</para>
</callout>
<callout arearefs="gfe#default-ns#beans-prefix">
<para>The beans namespace prefix declaration.</para>
</callout>
<callout arearefs="gfe#default-ns#beans-example">
<para>Bean declaration using the <literal>&lt;beans&gt;</literal> namespace. Notice the prefix.</para>
</callout>
<callout arearefs="gfe#default-ns#gfe-example">
<para>Bean declaration using the <literal>&lt;gfe&gt;</literal> namespace. Notice the lack of prefix (as the default namespace is used).</para>
</callout>
</calloutlist>
</programlistingco>
<para>For the remainder of this doc, to improve readability, the XML examples will simply refer to the <literal>&lt;gfe&gt;</literal> namespace
without the namespace declaration, where possible.</para>
</section>
<section id="bootstrap:cache">
<title>Configuring the GemFire
<title>Configuring the GemFire
<interfacename>Cache</interfacename></title>
<para>In order to use the GemFire Fabric, one needs to either create a new
@@ -24,8 +118,32 @@
<para>In its simplest form, a cache can be defined in one line:</para>
<!--
<programlisting language="xml">&lt;bean id="default-cache" class="org.springframework.data.gemfire.CacheFactoryBean"/&gt;</programlisting>
-->
<programlistingco>
<areaspec>
<area id="cache#ns" coords="3 137"/>
</areaspec>
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<gfe:cache />
</beans>]]>
</programlisting>
<calloutlist>
<callout arearefs="cache#ns">
<para>Spring GemFire namespace</para>
</callout>
</calloutlist>
</programlistingco>
<para>Here, the <emphasis>default-cache</emphasis> will try to connect to
an existing cache and, in case one does not exist, create it. Since no
additional properties were specified the created cache uses the default