Fix typos in XStream config
This commit is contained in:
@@ -1530,25 +1530,14 @@ assertEquals(born, values[2]);</programlisting>
|
||||
</itemizedlist></para>
|
||||
|
||||
<para><programlisting><bean id="itemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
|
||||
<property name="fragmentRootElementName" value="customer" />
|
||||
<property name="fragmentRootElementName" value="trade" />
|
||||
<property name="resource" value="data/iosample/input/input.xml" />
|
||||
<property name="unmarshaller" ref="customerCreditMarshaller" />
|
||||
<property name="unmarshaller" ref="tradeMarshaller" />
|
||||
</bean>
|
||||
|
||||
<bean id="customerCreditMarshaller"
|
||||
class="org.springframework.oxm.xstream.XStreamMarshaller">
|
||||
<property name="aliases">
|
||||
<util:map id="aliases">
|
||||
<entry key="customer"
|
||||
value="org.springframework.batch.sample.domain.CustomerCredit" />
|
||||
<entry key="price" value="java.math.BigDecimal" />
|
||||
<entry key="name" value="java.lang.String" />
|
||||
</util:map>
|
||||
</property>
|
||||
</bean></programlisting></para>
|
||||
</programlisting></para>
|
||||
|
||||
<para>Notice that in this example we have chosen to use an
|
||||
<classname>XStreamMarshaller</classname> that requires an alias passed
|
||||
<classname>XStreamMarshaller</classname> which accepts an alias passed
|
||||
in as a map with the first key and value being the name of the fragment
|
||||
(i.e. root element) and the object type to bind. Then, similar to a
|
||||
<classname>FieldSet</classname>, the names of the other elements that
|
||||
@@ -1556,18 +1545,12 @@ assertEquals(born, values[2]);</programlisting>
|
||||
the map. In the configuration file we can use a Spring configuration
|
||||
utility to describe the required alias as follows:</para>
|
||||
|
||||
<para><programlisting><bean id="itemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
|
||||
<property name="fragmentRootElementName" value="customer" />
|
||||
<property name="resource" value="data/iosample/input/input.xml" />
|
||||
<property name="unmarshaller" ref="customerCreditMarshaller" />
|
||||
</bean>
|
||||
|
||||
<bean id="customerCreditMarshaller"
|
||||
<para><programlisting><bean id="tradeMarshaller"
|
||||
class="org.springframework.oxm.xstream.XStreamMarshaller">
|
||||
<property name="aliases">
|
||||
<emphasis role="bold"> <util:map id="aliases">
|
||||
<entry key="customer"
|
||||
value="org.springframework.batch.sample.domain.CustomerCredit" />
|
||||
<entry key="trade"
|
||||
value="org.springframework.batch.sample.domain.Trade" />
|
||||
<entry key="price" value="java.math.BigDecimal" />
|
||||
<entry key="name" value="java.lang.String" />
|
||||
</util:map></emphasis>
|
||||
@@ -1590,14 +1573,14 @@ assertEquals(born, values[2]);</programlisting>
|
||||
Resource resource = new ByteArrayResource(xmlResource.getBytes())
|
||||
|
||||
Map aliases = new HashMap();
|
||||
aliases.put("customer","org.springframework.batch.sample.domain.CustomerCredit");
|
||||
aliases.put("trade","org.springframework.batch.sample.domain.Trade");
|
||||
aliases.put("price","java.math.BigDecimal");
|
||||
aliases.put("name","java.lang.String");
|
||||
aliases.put("customer","java.lang.String");
|
||||
Marshaller marshaller = new XStreamMarshaller();
|
||||
marshaller.setAliases(aliases);
|
||||
xmlStaxEventItemReader.setUnmarshaller(marshaller);
|
||||
xmlStaxEventItemReader.setResource(resource);
|
||||
xmlStaxEventItemReader.setFragmentRootElementName("customer");
|
||||
xmlStaxEventItemReader.setFragmentRootElementName("trade");
|
||||
xmlStaxEventItemReader.open(new ExecutionContext());
|
||||
|
||||
boolean hasNext = true
|
||||
@@ -1620,8 +1603,8 @@ while (hasNext) {
|
||||
|
||||
<para>Output works symmetrically to input. The
|
||||
<classname>StaxEventItemWriter</classname> needs a
|
||||
<classname>Resource</classname>, a serializer, and a rootTagName. A Java
|
||||
object is passed to a serializer (typically a wrapper around Spring OXM
|
||||
<classname>Resource</classname>, a marshaller, and a <literal>rootTagName</literal>. A Java
|
||||
object is passed to a marshaller (typically a standard Spring OXM
|
||||
<classname>Marshaller</classname>) which writes to a
|
||||
<classname>Resource</classname> using a custom event writer that filters
|
||||
the <classname>StartDocument</classname> and
|
||||
@@ -1649,7 +1632,7 @@ while (hasNext) {
|
||||
<util:map id="aliases">
|
||||
<entry key="customer"
|
||||
value="org.springframework.batch.sample.domain.CustomerCredit" />
|
||||
<entry key="price" value="java.math.BigDecimal" />
|
||||
<entry key="credit" value="java.math.BigDecimal" />
|
||||
<entry key="name" value="java.lang.String" />
|
||||
</util:map>
|
||||
</property>
|
||||
@@ -1664,7 +1647,7 @@ FileSystemResource resource = new FileSystemResource("data/outputFile.xml")
|
||||
|
||||
Map aliases = new HashMap();
|
||||
aliases.put("customer","org.springframework.batch.sample.domain.CustomerCredit");
|
||||
aliases.put("price","java.math.BigDecimal");
|
||||
aliases.put("credit","java.math.BigDecimal");
|
||||
aliases.put("name","java.lang.String");
|
||||
Marshaller marshaller = new XStreamMarshaller();
|
||||
marshaller.setAliases(aliases);
|
||||
|
||||
Reference in New Issue
Block a user