diff --git a/samples/src/main/java/org/springframework/batch/sample/item/provider/CollectionItemProvider.java b/samples/src/main/java/org/springframework/batch/sample/item/provider/CollectionItemProvider.java
index 2edd91ba4..642bc031a 100644
--- a/samples/src/main/java/org/springframework/batch/sample/item/provider/CollectionItemProvider.java
+++ b/samples/src/main/java/org/springframework/batch/sample/item/provider/CollectionItemProvider.java
@@ -23,7 +23,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.io.InputSource;
import org.springframework.batch.io.file.FieldSet;
-import org.springframework.batch.io.file.FieldSetInputSource;
import org.springframework.batch.io.file.FieldSetMapper;
import org.springframework.batch.item.ItemProvider;
import org.springframework.batch.item.provider.AbstractItemProvider;
@@ -32,32 +31,32 @@ import org.springframework.batch.item.provider.AbstractItemProvider;
* An {@link ItemProvider} that delivers a list as its item, storing up objects
* from the injected {@link InputSource} until they are ready to be packed out
* as a collection.
- *
+ *
* This class is thread safe (it can be used concurrently by multiple threads) as
* long as the {@link InputSource} is also thread safe.
- *
+ *
* @author Dave Syer
- *
+ *
*/
public class CollectionItemProvider extends AbstractItemProvider {
private static final Log log = LogFactory
.getLog(CollectionItemProvider.class);
- private FieldSetInputSource inputSource;
+ private InputSource inputSource;
// maps a single line to a simple record
private FieldSetMapper fieldSetMapper;
/**
* Get the next list of records.
- *
+ *
* @see org.springframework.batch.item.ItemProvider#next()
*/
public Object next() {
ResultHolder holder = new ResultHolder();
- while (process(inputSource.readFieldSet(), holder)) {
+ while (process((FieldSet)inputSource.read(), holder)) {
continue;
}
@@ -98,7 +97,7 @@ public class CollectionItemProvider extends AbstractItemProvider {
* Injection setter for {@link InputSource}.
* @param inputSource an {@link InputSource}.
*/
- public void setInputSource(FieldSetInputSource inputSource) {
+ public void setInputSource(InputSource inputSource) {
this.inputSource = inputSource;
}
@@ -109,9 +108,9 @@ public class CollectionItemProvider extends AbstractItemProvider {
/**
* Private class for temporary state management while item is being
* collected.
- *
+ *
* @author Dave Syer
- *
+ *
*/
private class ResultHolder {
Collection records = new ArrayList();
diff --git a/samples/src/main/java/org/springframework/batch/sample/item/provider/NflPlayerItemProvider.java b/samples/src/main/java/org/springframework/batch/sample/item/provider/NflPlayerItemProvider.java
deleted file mode 100644
index fa39b060a..000000000
--- a/samples/src/main/java/org/springframework/batch/sample/item/provider/NflPlayerItemProvider.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.springframework.batch.sample.item.provider;
-
-import org.springframework.batch.io.Skippable;
-import org.springframework.batch.io.file.FieldSetMapper;
-import org.springframework.batch.io.file.support.DefaultFlatFileInputSource;
-import org.springframework.batch.item.ItemProvider;
-import org.springframework.batch.restart.RestartData;
-import org.springframework.batch.restart.Restartable;
-import org.springframework.batch.sample.domain.NflPlayer;
-
-
-
-public class NflPlayerItemProvider implements ItemProvider, Restartable, Skippable{
-
- DefaultFlatFileInputSource inputSource = null;
-
- FieldSetMapper fieldSetMapper = null;
-
- public void setFieldSetMapper(FieldSetMapper fieldSetMapper) {
- this.fieldSetMapper = fieldSetMapper;
- }
-
- public void setInputSource(DefaultFlatFileInputSource inputSource) {
- this.inputSource = inputSource;
- }
-
- public Object getKey(Object item) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object next() throws Exception {
-
- NflPlayer nflPlayer = (NflPlayer)fieldSetMapper.mapLine(inputSource.readFieldSet());
- return nflPlayer;
- }
-
- public boolean recover(Object data, Throwable cause) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public RestartData getRestartData() {
- return inputSource.getRestartData();
- }
-
- public void restoreFrom(RestartData data) {
- inputSource.restoreFrom(data);
- }
-
- public void skip() {
- inputSource.skip();
- }
-
-}
diff --git a/samples/src/main/java/org/springframework/batch/sample/item/provider/OrderItemProvider.java b/samples/src/main/java/org/springframework/batch/sample/item/provider/OrderItemProvider.java
index ce04666c0..65bb1ee67 100644
--- a/samples/src/main/java/org/springframework/batch/sample/item/provider/OrderItemProvider.java
+++ b/samples/src/main/java/org/springframework/batch/sample/item/provider/OrderItemProvider.java
@@ -22,8 +22,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.core.domain.StepExecution;
+import org.springframework.batch.io.InputSource;
import org.springframework.batch.io.file.FieldSet;
-import org.springframework.batch.io.file.FieldSetInputSource;
import org.springframework.batch.io.file.FieldSetMapper;
import org.springframework.batch.item.provider.AbstractItemProvider;
import org.springframework.batch.item.validator.Validator;
@@ -42,7 +42,7 @@ import org.springframework.batch.sample.domain.ShippingInfo;
*/
public class OrderItemProvider extends AbstractItemProvider {
private static Log log = LogFactory.getLog(OrderItemProvider.class);
- private FieldSetInputSource inputSource;
+ private InputSource inputSource;
private Order order;
private boolean recordFinished;
private FieldSetMapper headerMapper;
@@ -60,7 +60,7 @@ public class OrderItemProvider extends AbstractItemProvider {
recordFinished = false;
while (!recordFinished) {
- process(inputSource.readFieldSet());
+ process((FieldSet)inputSource.read());
}
if (order!=null) {
@@ -70,7 +70,7 @@ public class OrderItemProvider extends AbstractItemProvider {
Object result = order;
order = null;
-
+
return result;
}
@@ -88,7 +88,7 @@ public class OrderItemProvider extends AbstractItemProvider {
}
String lineId = fieldSet.readString(0);
-
+
//start a new Order
if (Order.LINE_ID_HEADER.equals(lineId)) {
log.debug("STARTING NEW RECORD");
@@ -119,7 +119,7 @@ public class OrderItemProvider extends AbstractItemProvider {
order.setCustomer((Customer) customerMapper.mapLine(fieldSet));
order.getCustomer().setBusinessCustomer(true);
}
-
+
return;
}
@@ -130,7 +130,7 @@ public class OrderItemProvider extends AbstractItemProvider {
order.setCustomer((Customer) customerMapper.mapLine(fieldSet));
order.getCustomer().setBusinessCustomer(false);
}
-
+
return;
}
@@ -166,10 +166,10 @@ public class OrderItemProvider extends AbstractItemProvider {
}
order.getLineItems().add(itemMapper.mapLine(fieldSet));
-
+
return;
}
-
+
log.debug("Could not map LINE_ID="+lineId);
}
@@ -190,8 +190,8 @@ public class OrderItemProvider extends AbstractItemProvider {
this.headerMapper = headerMapper;
}
- public void setInputSource(FieldSetInputSource inputTemplate) {
- this.inputSource = inputTemplate;
+ public void setInputSource(InputSource inputSource) {
+ this.inputSource = inputSource;
}
public void setItemMapper(FieldSetMapper itemMapper) {
@@ -205,5 +205,5 @@ public class OrderItemProvider extends AbstractItemProvider {
public void setValidator(Validator validator) {
this.validator = validator;
}
-
+
}
diff --git a/samples/src/main/java/org/springframework/batch/sample/item/provider/SkipSampleItemProvider.java b/samples/src/main/java/org/springframework/batch/sample/item/provider/SkipSampleItemProvider.java
deleted file mode 100644
index ffe6b3fb4..000000000
--- a/samples/src/main/java/org/springframework/batch/sample/item/provider/SkipSampleItemProvider.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.batch.sample.item.provider;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.batch.io.exception.TransactionInvalidException;
-import org.springframework.batch.io.file.FieldSetInputSource;
-import org.springframework.batch.io.file.FieldSetMapper;
-import org.springframework.batch.item.provider.AbstractItemProvider;
-
-/**
- * @author peter.zozom
- *
- */
-public class SkipSampleItemProvider extends AbstractItemProvider {
-
- private static Log log = LogFactory.getLog(SkipSampleItemProvider.class);
-
- private int counter = 0;
-
- private int exceptionOnrecordNumber = 14;
-
- private FieldSetInputSource inputSource;
-
- private FieldSetMapper fieldSetMapper;
-
- public Object next() {
- counter++;
-
- if (counter == exceptionOnrecordNumber) {
- // this causes rollback of current transaction
- log.debug("Throwing TransactionInvalidException to cause transaction rollback...");
- throw new TransactionInvalidException("Error processing line: " + counter + ". Rollbacking...");
- }
-
- return fieldSetMapper.mapLine(inputSource.readFieldSet());
- }
-
- public void setInputSource(FieldSetInputSource inputTemplate) {
- this.inputSource = inputTemplate;
- }
-
- public void setFieldSetMapper(FieldSetMapper fieldSetMapper) {
- this.fieldSetMapper = fieldSetMapper;
- }
-
- public void setThrowExceptionOnRecordNumber(int exceptionOnrecordNumber) {
- this.exceptionOnrecordNumber = exceptionOnrecordNumber;
- }
-
-}
diff --git a/samples/src/main/java/org/springframework/batch/sample/mapping/PassThroughFieldSetMapper.java b/samples/src/main/java/org/springframework/batch/sample/mapping/PassThroughFieldSetMapper.java
new file mode 100644
index 000000000..653bd9e91
--- /dev/null
+++ b/samples/src/main/java/org/springframework/batch/sample/mapping/PassThroughFieldSetMapper.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.batch.sample.mapping;
+
+import org.springframework.batch.io.file.FieldSet;
+import org.springframework.batch.io.file.FieldSetMapper;
+
+/**
+ * Pass through {@link FieldSetMapper} useful for
+ * passing a fieldset back from a FlatFileInputsource rather
+ * than a mapped object.
+ *
+ * @author Lucas Ward
+ *
+ */
+public class PassThroughFieldSetMapper implements FieldSetMapper {
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.io.file.FieldSetMapper#mapLine(org.springframework.batch.io.file.FieldSet)
+ */
+ public Object mapLine(FieldSet fs) {
+ return fs;
+ }
+
+}
diff --git a/samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java b/samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java
index 08c381ff8..13b4ada97 100644
--- a/samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java
+++ b/samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java
@@ -34,35 +34,26 @@ import org.springframework.batch.statistics.StatisticsProvider;
* reading and processing logic need not to be reused in different contexts. In
* general it is recommended to separate these two concerns using an
* {@link ItemProviderProcessTasklet}.
- *
+ *
* Note this class is thread-safe, as per the 'standard' module implementations
* provided by the framework.
- *
+ *
* @author Robert Kasanicky
* @author Lucas Ward
* @author Dave Syer
*/
public class SimpleTradeTasklet implements Tasklet, StatisticsProvider {
- /**
+
+ /*
* reads the data from input file
*/
private DefaultFlatFileInputSource inputSource;
- /**
- * maps a line to a Trade object
- */
- private FieldSetMapper tradeFieldSetMapper = new TradeFieldSetMapper();
-
- /**
+ /*
* writes a Trade object to output
*/
private TradeWriter tradeWriter;
- /**
- * domain object being processed
- */
- private Trade trade;
-
/**
* number of trade objects processed
*/
@@ -75,7 +66,7 @@ public class SimpleTradeTasklet implements Tasklet, StatisticsProvider {
* written out without any processing.
*/
public ExitStatus execute() throws Exception {
- trade = (Trade) tradeFieldSetMapper.mapLine(inputSource.readFieldSet());
+ Trade trade = (Trade)inputSource.read();
if (trade == null) {
// no Trade object returned, reading input is finished
@@ -87,30 +78,6 @@ public class SimpleTradeTasklet implements Tasklet, StatisticsProvider {
return ExitStatus.CONTINUABLE;
}
- /**
- * Inner class which implements the FieldSetMapper interface. It contains
- * one method, mapLine, which accepts a FieldSet as a parameter. This method
- * will be called by the inputSource when it is passed in.
- *
- */
- private static class TradeFieldSetMapper implements FieldSetMapper {
- public Object mapLine(FieldSet fieldSet) {
-
- if (fieldSet == null) {
- return null;
- }
-
- Trade trade = new Trade();
- trade.setIsin(fieldSet.readString("ISIN"));
- trade.setQuantity(fieldSet.readLong(1));
- trade.setPrice(fieldSet.readBigDecimal(2));
- trade.setCustomer(fieldSet.readString(3));
-
- return trade;
-
- }
- }
-
public void setInputSource(DefaultFlatFileInputSource inputTemplate) {
this.inputSource = inputTemplate;
}
diff --git a/samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml b/samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml
index 093337e45..9282cb9ab 100644
--- a/samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml
+++ b/samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml
@@ -20,9 +20,8 @@
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
-
-
+ class="org.springframework.batch.item.provider.ValidatingItemProvider">
+
@@ -40,9 +39,8 @@
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
-
-
+ class="org.springframework.batch.item.provider.InputSourceItemProvider">
+
@@ -63,6 +61,7 @@
+
+
diff --git a/samples/src/main/resources/jobs/compositeProcessorSampleJob.xml b/samples/src/main/resources/jobs/compositeProcessorSampleJob.xml
index 340ed93fc..06e7e69fc 100644
--- a/samples/src/main/resources/jobs/compositeProcessorSampleJob.xml
+++ b/samples/src/main/resources/jobs/compositeProcessorSampleJob.xml
@@ -14,14 +14,13 @@
-
+
-
-
+ class="org.springframework.batch.item.provider.ValidatingItemProvider">
+
@@ -32,7 +31,7 @@
-
+
@@ -53,6 +52,7 @@
+
@@ -83,11 +83,11 @@
-
+
-
+
@@ -103,5 +103,5 @@
-
+
\ No newline at end of file
diff --git a/samples/src/main/resources/jobs/fixedLengthImportJob.xml b/samples/src/main/resources/jobs/fixedLengthImportJob.xml
index ca8be559b..dcefaacb4 100644
--- a/samples/src/main/resources/jobs/fixedLengthImportJob.xml
+++ b/samples/src/main/resources/jobs/fixedLengthImportJob.xml
@@ -19,9 +19,8 @@
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
-
-
+ class="org.springframework.batch.item.provider.ValidatingItemProvider">
+
@@ -42,6 +41,7 @@
abstract="true">
+
@@ -51,7 +51,7 @@
-
+
diff --git a/samples/src/main/resources/jobs/multilineJob.xml b/samples/src/main/resources/jobs/multilineJob.xml
index 2b2939e13..57956487b 100644
--- a/samples/src/main/resources/jobs/multilineJob.xml
+++ b/samples/src/main/resources/jobs/multilineJob.xml
@@ -1,7 +1,7 @@
@@ -18,7 +18,7 @@
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
-
+
@@ -39,11 +39,14 @@
-
+
+
+
@@ -68,18 +71,18 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/samples/src/main/resources/jobs/multilineOrderIo.xml b/samples/src/main/resources/jobs/multilineOrderIo.xml
index b2bdc7f58..6523f998f 100644
--- a/samples/src/main/resources/jobs/multilineOrderIo.xml
+++ b/samples/src/main/resources/jobs/multilineOrderIo.xml
@@ -1,9 +1,9 @@
-
@@ -13,6 +13,9 @@
+
+
+
-
+
\ No newline at end of file
diff --git a/samples/src/main/resources/jobs/restartSample.xml b/samples/src/main/resources/jobs/restartSample.xml
index a7d76fb4c..9c7436bed 100644
--- a/samples/src/main/resources/jobs/restartSample.xml
+++ b/samples/src/main/resources/jobs/restartSample.xml
@@ -18,9 +18,8 @@
-
-
+ class="org.springframework.batch.item.provider.ValidatingItemProvider">
+
@@ -41,11 +40,12 @@
-
+
diff --git a/samples/src/main/resources/jobs/simpleTaskletJob.xml b/samples/src/main/resources/jobs/simpleTaskletJob.xml
index c180d02a7..ad37fd317 100644
--- a/samples/src/main/resources/jobs/simpleTaskletJob.xml
+++ b/samples/src/main/resources/jobs/simpleTaskletJob.xml
@@ -1,7 +1,7 @@
@@ -10,7 +10,7 @@
-
+
@@ -38,13 +38,8 @@
-
-
-
-
-
- /data/simpleTaskletJob/input/20070122.teststream.ImportTradeDataStep.txt
-
+
+
@@ -54,26 +49,33 @@
-
+
-
+
+
+
+
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
diff --git a/samples/src/main/resources/jobs/tradeJob.xml b/samples/src/main/resources/jobs/tradeJob.xml
index 1f8040ba8..2d24cacab 100644
--- a/samples/src/main/resources/jobs/tradeJob.xml
+++ b/samples/src/main/resources/jobs/tradeJob.xml
@@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
@@ -27,13 +27,9 @@
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
-
+
-
-
-
@@ -127,6 +123,6 @@
-
+
\ No newline at end of file
diff --git a/samples/src/main/resources/jobs/tradeJobIo.xml b/samples/src/main/resources/jobs/tradeJobIo.xml
index 7a588260d..ad4420b29 100644
--- a/samples/src/main/resources/jobs/tradeJobIo.xml
+++ b/samples/src/main/resources/jobs/tradeJobIo.xml
@@ -32,6 +32,9 @@
+
+
+