Fix StaxEventItemReader example in docs

Problem:  When invoking xmlStaxEventItemReader.setUnmarshaller() one
          would get incompatible types as o.s.oxm.Marshaller cannot be
          converted to o.s.oxm.Unmarshaller.
Solution: Change type of marshaller to o.s.oxm.Unmarshaller.

Problem:  Changing the type of the marshaller variable to Unmarshaller
          would result in an unknown symbol setAliases() because
          Unmarshaller does not cover that method.
Solution: Just use the concrete type XStreamMarshaller.

Problem:  The variable name for our XStreamMarshaller which is used as
          Unmarshaller is called marshaller.
Solution: Rename the variable to unmarshaller.

See:
http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/oxm/xstream/XStreamMarshaller.html
http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/oxm/Unmarshaller.html
http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/oxm/Marshaller.html
This commit is contained in:
Lorenz Leutgeb
2016-08-03 11:11:20 +02:00
committed by GitHub
parent 0d9a5e3aed
commit c7df668a31

View File

@@ -1593,9 +1593,9 @@ Map aliases = new HashMap();
aliases.put("trade","org.springframework.batch.sample.domain.Trade");
aliases.put("price","java.math.BigDecimal");
aliases.put("customer","java.lang.String");
Marshaller marshaller = new XStreamMarshaller();
marshaller.setAliases(aliases);
xmlStaxEventItemReader.setUnmarshaller(marshaller);
XStreamMarshaller unmarshaller = new XStreamMarshaller();
unmarshaller.setAliases(aliases);
xmlStaxEventItemReader.setUnmarshaller(unmarshaller);
xmlStaxEventItemReader.setResource(resource);
xmlStaxEventItemReader.setFragmentRootElementName("trade");
xmlStaxEventItemReader.open(new ExecutionContext());