Java Reference
In-Depth Information
<processor ref="acmeProcessor"></processor>
<step id="writingStep" >
<chunk item-count="1">
<writer ref="acmeWriter"></writer>
There are three tasks being performed in this particular job: acmeReader , acmeProcessor , and acmeWriter . These
three tasks can be associated with Java class implementations within the batch.xml file, which is located within the
META-INF directory. The following code shows what the batch.xml looks like.
<?xml version="1.0" encoding="UTF-8"?>
<batch-artifacts xmlns=" ">
<ref id="acmeReader" class="org.javaee7.chapter11.AcmeReader"/>
<ref id="acmeProcessor" class="org.javaee7.chapter11.AcmeProcessor"/>
<ref id="acmeWriter" class="org.javaee7.chapter11.AcmeWriter"/>
Next, let's take a look at each of these class implementations. We will begin by looking at the AcmeReader class
implementation below. This class is responsible for reading a file and creating a new WidgetReportItem object for
each line of text.
package org.javaee7.chapter11;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import javax.batch.api.AbstractItemReader;
* Example of a file reading task
* @author Juneau
public class AcmeReader extends AbstractItemReader<WidgetReportItem> {
public AcmeReader() {
* Read lines of report and store each into a WidgetReportItem object. Once
* all lines have been read then return null to trigger the end of file.
* @return
* @throws Exception
Search WWH ::

Custom Search