OPEN - issue BATCH-320: Refactor ItemWriter as primary collaborator (with wrapper for processor)

http://jira.springframework.org/browse/BATCH-320

Remove some references to "processor".  Rename some XML files.
This commit is contained in:
dsyer
2008-01-29 09:35:11 +00:00
parent a98f0e566c
commit bc9afc4ce1
11 changed files with 39 additions and 39 deletions

View File

@@ -71,14 +71,14 @@ import org.springframework.util.Assert;
public class ItemOrientedTasklet implements Tasklet, Skippable, InitializingBean {
/**
* Prefix added to statistics keys from processor if needed to avoid
* ambiguity between provider and processor.
* Prefix added to statistics keys from writer if needed to avoid
* ambiguity between reader and writer.
*/
public static final String PROCESSOR_STATISTICS_PREFIX = "processor.";
public static final String PROCESSOR_STATISTICS_PREFIX = "writer.";
/**
* Prefix added to statistics keys from provider if needed to avoid
* ambiguity between provider and processor.
* Prefix added to statistics keys from reader if needed to avoid
* ambiguity between provider and writer.
*/
public static final String PROVIDER_STATISTICS_PREFIX = "provider.";
@@ -95,7 +95,7 @@ public class ItemOrientedTasklet implements Tasklet, Skippable, InitializingBean
private ItemReaderRetryCallback retryCallback;
/**
* Check mandatory properties (provider and processor).
* Check mandatory properties (reader and writer).
*
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@@ -182,8 +182,8 @@ public class ItemOrientedTasklet implements Tasklet, Skippable, InitializingBean
/**
* Mark the current item as skipped if possible. If there is a retry policy
* in action there is no need to take any action now because it will be
* covered by the retry in the next transaction. Otherwise if the provider
* and / or processor are {@link Skippable} then delegate to them in that
* covered by the retry in the next transaction. Otherwise if the reader
* and / or writer are {@link Skippable} then delegate to them in that
* order.
*
* @see org.springframework.batch.io.Skippable#skip()

View File

@@ -27,7 +27,7 @@ import org.springframework.batch.support.PropertiesConverter;
/**
* An extension of {@link ItemOrientedTasklet} that delegates calls to
* {@link Restartable} to the provider and processor.
* {@link Restartable} to the reader and writer.
*
* @see ItemReader
* @see ItemWriter
@@ -77,42 +77,42 @@ public class RestartableItemOrientedTasklet extends ItemOrientedTasklet implemen
}
if (itemProvider instanceof Restartable) {
((Restartable) itemProvider).restoreFrom(moduleRestartData.providerData);
((Restartable) itemProvider).restoreFrom(moduleRestartData.readerData);
}
if (itemWriter instanceof Restartable) {
((Restartable) itemWriter).restoreFrom(moduleRestartData.processorData);
((Restartable) itemWriter).restoreFrom(moduleRestartData.writerData);
}
}
private class RestartableItemOrientedTaskletRestartData implements RestartData {
private static final String PROVIDER_KEY = "DATA_PROVIDER";
private static final String READER_KEY = "DATA_PROVIDER";
private static final String PROCESSOR_KEY = "DATA_PROCESSOR";
private static final String WRITER_KEY = "DATA_PROCESSOR";
RestartData providerData;
private RestartData readerData;
RestartData processorData;
private RestartData writerData;
public RestartableItemOrientedTaskletRestartData(RestartData providerData, RestartData processorData) {
this.providerData = providerData;
this.processorData = processorData;
public RestartableItemOrientedTaskletRestartData(RestartData providerData, RestartData writerData) {
this.readerData = providerData;
this.writerData = writerData;
}
public RestartableItemOrientedTaskletRestartData(Properties data) {
providerData = new GenericRestartData(PropertiesConverter
.stringToProperties(data.getProperty(PROVIDER_KEY)));
processorData = new GenericRestartData(PropertiesConverter.stringToProperties(data
.getProperty(PROCESSOR_KEY)));
readerData = new GenericRestartData(PropertiesConverter
.stringToProperties(data.getProperty(READER_KEY)));
writerData = new GenericRestartData(PropertiesConverter.stringToProperties(data
.getProperty(WRITER_KEY)));
}
public Properties getProperties() {
Properties props = new Properties();
if (providerData != null) {
props.setProperty(PROVIDER_KEY, PropertiesConverter.propertiesToString(providerData.getProperties()));
if (readerData != null) {
props.setProperty(READER_KEY, PropertiesConverter.propertiesToString(readerData.getProperties()));
}
if (processorData != null) {
props.setProperty(PROCESSOR_KEY, PropertiesConverter.propertiesToString(processorData.getProperties()));
if (writerData != null) {
props.setProperty(WRITER_KEY, PropertiesConverter.propertiesToString(writerData.getProperties()));
}
return props;
}

View File

@@ -256,7 +256,7 @@ public class ItemOrientedTaskletTests extends TestCase {
try {
module.afterPropertiesSet();
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().toLowerCase().indexOf("processor") >= 0);
assertTrue(e.getMessage().toLowerCase().indexOf("writer") >= 0);
}
}
@@ -294,7 +294,7 @@ public class ItemOrientedTaskletTests extends TestCase {
}
public void skip() {
list.add("processor");
list.add("writer");
}
public Properties getStatistics() {

View File

@@ -31,7 +31,7 @@ public interface ItemWriter {
* larger batch operation. Will not be called with null data in normal
* operation.
*
* @throws Exception if there are errors. If the processor is used inside a
* @throws Exception if there are errors. If the writer is used inside a
* retry or a batch the framework will catch the exception and convert or
* rethrow it as appropriate.
*/

View File

@@ -105,9 +105,9 @@ public class CompositeItemWriter implements ItemWriter, Restartable {
Properties stats = new Properties();
int index = 0;
for (Iterator iterator = delegates.listIterator(); iterator.hasNext();) {
Properties processorStats = extractor.extractProperties(iterator.next());
if (processorStats != null) {
for (Iterator iterator2 = processorStats.entrySet().iterator(); iterator2.hasNext();) {
Properties writerStats = extractor.extractProperties(iterator.next());
if (writerStats != null) {
for (Iterator iterator2 = writerStats.entrySet().iterator(); iterator2.hasNext();) {
Map.Entry entry = (Map.Entry) iterator2.next();
stats.setProperty("" + index + SEPARATOR + entry.getKey(), (String) entry.getValue());
}

View File

@@ -42,7 +42,7 @@ public class ItemReaderRepeatCallback implements RepeatCallback {
}
/**
* Default processor is null, in which case we do nothing - subclasses can
* Default writer is null, in which case we do nothing - subclasses can
* extend this behaviour, but must be careful to actually exhaust the
* provider by calling next().
* @param provider

View File

@@ -4,7 +4,7 @@ import java.util.List;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.io.sample.domain.FooService;
import org.springframework.batch.item.writer.ItemWriterAdapter;
import org.springframework.batch.item.ItemWriter;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
/**
@@ -14,13 +14,13 @@ import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
*/
public class ItemWriterAdapterIntegrationTests extends AbstractDependencyInjectionSpringContextTests {
private ItemWriterAdapter processor;
private ItemWriter processor;
private FooService fooService;
protected String getConfigPath() {
return "delegating-item-processor.xml";
return "delegating-item-writer.xml";
}
/**
@@ -45,7 +45,7 @@ public class ItemWriterAdapterIntegrationTests extends AbstractDependencyInjecti
}
//setter for auto-injection
public void setProcessor(ItemWriterAdapter processor) {
public void setProcessor(ItemWriter processor) {
this.processor = processor;
}

View File

@@ -20,7 +20,7 @@ public class PropertyExtractingDelegatingItemProccessorIntegrationTests
private FooService fooService;
protected String getConfigPath() {
return "pe-delegating-item-processor.xml";
return "pe-delegating-item-writer.xml";
}
/**

View File

@@ -45,7 +45,7 @@ public class FlatFileOrderWriter extends DelegatingItemWriter {
}
/* (non-Javadoc)
* @see org.springframework.batch.item.processor.DelegatingItemWriter#doProcess(java.lang.Object)
* @see org.springframework.batch.item.writer.DelegatingItemWriter#doProcess(java.lang.Object)
*/
protected Object doProcess(Object item) throws Exception {
return transformer.transform(item);