diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchListenerFactoryHelper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchListenerFactoryHelper.java index 7a3e7dfc3..5bda9fd88 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchListenerFactoryHelper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchListenerFactoryHelper.java @@ -28,8 +28,6 @@ import org.springframework.batch.core.StepListener; import org.springframework.batch.core.listener.CompositeChunkListener; import org.springframework.batch.core.listener.CompositeItemReadListener; import org.springframework.batch.core.listener.CompositeItemWriteListener; -import org.springframework.batch.item.ClearFailedException; -import org.springframework.batch.item.FlushFailedException; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.DelegatingItemReader; @@ -95,6 +93,7 @@ abstract class BatchListenerFactoryHelper { } return new ItemWriter() { + public void write(List items) throws Exception { for (T item : items) { @@ -110,13 +109,6 @@ abstract class BatchListenerFactoryHelper { } } - public void flush() throws FlushFailedException { - itemWriter.flush(); - } - - public void clear() throws ClearFailedException { - itemWriter.clear(); - } }; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java index d454fbbbf..05247134a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java @@ -20,8 +20,6 @@ import java.util.Collections; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.StepContribution; -import org.springframework.batch.item.ClearFailedException; -import org.springframework.batch.item.FlushFailedException; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -142,16 +140,4 @@ public class ItemOrientedStepHandler implements StepHandler { itemReader.reset(); } - /** - * @throws ClearFailedException - */ - public void clear() throws ClearFailedException { - } - - /** - * @throws FlushFailedException - */ - public void flush() throws FlushFailedException { - } - } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandler.java index 0e0f86077..b11ae5a2d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandler.java @@ -16,8 +16,6 @@ package org.springframework.batch.core.step.item; import org.springframework.batch.core.StepContribution; -import org.springframework.batch.item.ClearFailedException; -import org.springframework.batch.item.FlushFailedException; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.MarkFailedException; @@ -61,16 +59,4 @@ public interface StepHandler { */ void reset() throws ResetFailedException; - /** - * Implementations should delegate to an {@link ItemWriter}. - * @deprecated - */ - public void flush() throws FlushFailedException; - - /** - * Implementations should delegate to an {@link ItemWriter}. - * @deprecated - */ - public void clear() throws ClearFailedException; - } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandlerStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandlerStep.java index 8469d86e5..88064aa95 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandlerStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandlerStep.java @@ -379,10 +379,6 @@ public class StepHandlerStep extends AbstractStep { } }); - // Attempt to flush before the step execution and stream - // state are updated - itemHandler.flush(); - return result; } @@ -405,7 +401,6 @@ public class StepHandlerStep extends AbstractStep { try { itemHandler.reset(); - itemHandler.clear(); transactionManager.rollback(transaction); } catch (Exception e) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepHandlerTests.java index f5d840f6d..21fbac41a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepHandlerTests.java @@ -26,11 +26,11 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.NoWorkFoundException; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; import org.springframework.batch.item.support.AbstractItemReader; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.batch.item.support.PassthroughItemProcessor; /** @@ -90,7 +90,7 @@ public class ItemOrientedStepHandlerTests { * @author Dave Syer * */ - private final class StubItemWriter extends AbstractItemWriter { + private final class StubItemWriter implements ItemWriter { private String values = ""; public void write(List items) throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index d319339ac..ca6adc1f8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -40,7 +40,6 @@ import org.springframework.batch.core.repository.support.SimpleJobRepository; import org.springframework.batch.core.step.AbstractStep; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.batch.item.support.ListItemReader; import org.springframework.batch.repeat.RepeatContext; import org.springframework.batch.repeat.exception.ExceptionHandler; @@ -63,7 +62,7 @@ public class SimpleStepFactoryBeanTests extends TestCase { private List written = new ArrayList(); - private ItemWriter writer = new AbstractItemWriter() { + private ItemWriter writer = new ItemWriter() { public void write(List data) throws Exception { written.addAll(data); } @@ -165,7 +164,7 @@ public class SimpleStepFactoryBeanTests extends TestCase { */ SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); - factory.setItemWriter(new AbstractItemWriter() { + factory.setItemWriter(new ItemWriter() { public void write(List data) throws Exception { throw new RuntimeException("Error!"); } @@ -198,7 +197,7 @@ public class SimpleStepFactoryBeanTests extends TestCase { public void testExceptionTerminates() throws Exception { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setBeanName("exceptionStep"); - factory.setItemWriter(new AbstractItemWriter() { + factory.setItemWriter(new ItemWriter() { public void write(List data) throws Exception { throw new RuntimeException("Foo"); } @@ -222,7 +221,7 @@ public class SimpleStepFactoryBeanTests extends TestCase { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setBeanName("exceptionStep"); factory.setExceptionHandler(new SimpleLimitExceptionHandler(1)); - factory.setItemWriter(new AbstractItemWriter() { + factory.setItemWriter(new ItemWriter() { int count = 0; public void write(List data) throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java index 2573949d7..0ad802a10 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java @@ -42,7 +42,6 @@ import org.springframework.batch.core.step.skip.SkipLimitExceededException; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.AbstractItemReader; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.batch.item.support.ListItemReader; import org.springframework.batch.retry.RetryException; import org.springframework.batch.retry.policy.RetryCacheCapacityExceededException; @@ -72,7 +71,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { JobExecution jobExecution; - private ItemWriter processor = new AbstractItemWriter() { + private ItemWriter processor = new ItemWriter() { public void write(List data) throws Exception { processed.addAll(data); } @@ -198,7 +197,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { } }; - ItemWriter itemWriter = new AbstractItemWriter() { + ItemWriter itemWriter = new ItemWriter() { public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); if (item.contains("b") || item.contains("d")) { @@ -236,7 +235,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { return item; } }; - ItemWriter itemWriter = new AbstractItemWriter() { + ItemWriter itemWriter = new ItemWriter() { public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); throw new RuntimeException("Write error - planned but retryable."); @@ -273,7 +272,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { return item; } }; - ItemWriter itemWriter = new AbstractItemWriter() { + ItemWriter itemWriter = new ItemWriter() { public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); throw new RuntimeException("Write error - planned but retryable."); @@ -311,7 +310,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { return item; } }; - ItemWriter itemWriter = new AbstractItemWriter() { + ItemWriter itemWriter = new ItemWriter() { public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); throw new RuntimeException("Write error - planned but retryable."); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java index 0c665fba2..3c5001677 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java @@ -33,8 +33,8 @@ import org.springframework.batch.core.repository.dao.MapJobInstanceDao; import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.support.SimpleJobRepository; import org.springframework.batch.core.step.StepExecutionSynchronizer; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.AbstractItemReader; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; import org.springframework.batch.repeat.support.RepeatTemplate; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; @@ -45,7 +45,7 @@ public class StepExecutorInterruptionTests extends TestCase { private JobExecution jobExecution; - private AbstractItemWriter itemWriter; + private ItemWriter itemWriter; private StepExecution stepExecution; @@ -64,7 +64,7 @@ public class StepExecutorInterruptionTests extends TestCase { jobExecution = jobRepository.createJobExecution(jobConfiguration, new JobParameters()); step.setJobRepository(jobRepository); step.setTransactionManager(new ResourcelessTransactionManager()); - itemWriter = new AbstractItemWriter() { + itemWriter = new ItemWriter() { public void write(List item) throws Exception { } }; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepIntegrationTests.java index 49b918679..c6eeb226e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepIntegrationTests.java @@ -41,7 +41,7 @@ import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.ListItemReader; import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; import org.springframework.batch.repeat.support.RepeatTemplate; @@ -112,7 +112,7 @@ public class StepHandlerStepIntegrationTests { public void testStatusForCommitFailedException() throws Exception { step.setItemHandler(new SimpleStepHandler(getReader(new String[] { "a", "b", "c" }), - new AbstractItemWriter() { + new ItemWriter() { public void write(List data) throws Exception { TransactionSynchronizationManager .registerSynchronization(new TransactionSynchronizationAdapter() { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepTests.java index 9e85b02cd..911a8424d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepTests.java @@ -53,7 +53,6 @@ import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.MarkFailedException; import org.springframework.batch.item.ResetFailedException; import org.springframework.batch.item.support.AbstractItemReader; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.batch.item.support.ListItemReader; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy; @@ -70,7 +69,7 @@ public class StepHandlerStepTests extends TestCase { private List list = new ArrayList(); - ItemWriter itemWriter = new AbstractItemWriter() { + ItemWriter itemWriter = new ItemWriter() { public void write(List data) throws Exception { processed.addAll(data); } diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java index 19716e7dc..095bd45d8 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java @@ -29,8 +29,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.item.ItemRecoverer; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.AbstractItemReader; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.batch.retry.RecoveryCallback; import org.springframework.batch.retry.RetryCallback; import org.springframework.batch.retry.RetryContext; @@ -108,7 +108,7 @@ public class ExternalRetryTests { retryTemplate.setRetryPolicy(new RecoveryCallbackRetryPolicy()); - final AbstractItemWriter writer = new AbstractItemWriter() { + final ItemWriter writer = new ItemWriter() { public void write(final List texts) { for (Object text : texts) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemWriter.java index 0c4570249..06e61e106 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemWriter.java @@ -27,11 +27,10 @@ import java.util.List; *

* *

- * Due to the nature of batch processing, it is expected that most writers will - * buffer output. A flush method is provided to the interface in order to ensure - * that any buffers can be flushed before a transaction is committed. Along the - * same lines, if a transaction has been rolled back, then the contents of any - * buffers should be thrown away. + * The write method is responsible for making sure that any internal buffers are + * flushed. If a transaction is active it will also usually be necessary to + * discard the output on a subsequent rollback. The resource to which the writer + * is sending data should normally be able to handle this itself. *

* * @author Dave Syer @@ -40,33 +39,12 @@ import java.util.List; public interface ItemWriter { /** - * Process the supplied data element. Will be called multiple times during a - * larger batch operation. Will not be called with null data in normal - * operation. + * Process the supplied data element. Will not be called with any null items + * in normal operation. * - * @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. + * @throws Exception if there are errors. The framework will catch the + * exception and convert or rethrow it as appropriate. */ void write(List items) throws Exception; - /** - * Flush any buffers that are being held. This will usually be performed - * prior to committing any transactions. - * @throws FlushFailedException in case of an error. If this exception is - * thrown the writer may be in an inconsistent state and manual intervention - * might be required to reconcile the data with persistent output. - * @deprecated - */ - void flush() throws FlushFailedException; - - /** - * Clear any buffers that are being held. This will usually be performed - * prior to rolling back any transactions. - * @throws ClearFailedException in case of an error. If this exception is - * thrown the writer may be in an inconsistent state and manual intervention - * might be required to reconcile the data with persistent output. - * @deprecated - */ - void clear() throws ClearFailedException; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java index b76391d18..57b5d6b9c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java @@ -18,8 +18,6 @@ package org.springframework.batch.item.adapter; import java.util.List; -import org.springframework.batch.item.ClearFailedException; -import org.springframework.batch.item.FlushFailedException; import org.springframework.batch.item.ItemWriter; @@ -38,20 +36,6 @@ public class ItemWriterAdapter extends AbstractMethodInvokingDelegator imp invokeDelegateMethodWithArgument(item); } } - - /* - * No-op, can't call more than one method. - * - */ - public void clear() throws ClearFailedException { - } - - /* - * No-op, can't call more than one method. - * - */ - public void flush() throws FlushFailedException { - } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java index 9741ccf16..2c547bbf4 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java @@ -18,8 +18,6 @@ package org.springframework.batch.item.adapter; import java.util.List; -import org.springframework.batch.item.ClearFailedException; -import org.springframework.batch.item.FlushFailedException; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; @@ -73,9 +71,4 @@ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInv this.fieldsUsedAsTargetMethodArguments = fieldsUsedAsMethodArguments; } - public void clear() throws ClearFailedException { - } - - public void flush() throws FlushFailedException { - } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriter.java index 25d565bfc..9c22172a7 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriter.java @@ -20,7 +20,6 @@ import java.sql.SQLException; import java.util.List; import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; @@ -52,7 +51,7 @@ import org.springframework.util.Assert; * @author Dave Syer * */ -public class BatchSqlUpdateItemWriter extends AbstractItemWriter implements InitializingBean { +public class BatchSqlUpdateItemWriter implements ItemWriter, InitializingBean { private JdbcOperations jdbcTemplate; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateAwareItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateAwareItemWriter.java index 122693425..d2a9a21ee 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateAwareItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateAwareItemWriter.java @@ -19,7 +19,6 @@ import java.util.List; import org.hibernate.SessionFactory; import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.beans.factory.InitializingBean; import org.springframework.orm.hibernate3.HibernateOperations; import org.springframework.orm.hibernate3.HibernateTemplate; @@ -29,11 +28,7 @@ import org.springframework.util.Assert; * {@link ItemWriter} that is aware of the Hibernate session and can take some * responsibilities to do with chunk boundaries away from a less smart * {@link ItemWriter} (the delegate). A delegate is required, and will be used - * to do the actual writing of the item.
- * - * It is expected that {@link #write(List)} is called inside a transaction, and - * that {@link #flush()} is then subsequently called before the transaction - * commits, or {@link #clear()} before it rolls back.
+ * to do the actual writing of the item.

* * The writer is thread safe after its properties are set (normal singleton * behaviour), so it can be used to write in multiple concurrent transactions. @@ -45,7 +40,7 @@ import org.springframework.util.Assert; * @author Dave Syer * */ -public class HibernateAwareItemWriter extends AbstractItemWriter implements InitializingBean { +public class HibernateAwareItemWriter implements ItemWriter, InitializingBean { private ItemWriter delegate; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaAwareItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaAwareItemWriter.java index 5fcd7a5c8..08f8c60e6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaAwareItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaAwareItemWriter.java @@ -6,7 +6,6 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.orm.jpa.EntityManagerFactoryUtils; @@ -36,7 +35,7 @@ import org.springframework.util.Assert; * @author Thomas Risberg * */ -public class JpaAwareItemWriter extends AbstractItemWriter implements InitializingBean { +public class JpaAwareItemWriter implements ItemWriter, InitializingBean { private ItemWriter delegate; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java index c81bcd65f..4e315e33b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.springframework.batch.item.ClearFailedException; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.FlushFailedException; import org.springframework.batch.item.ItemStream; @@ -53,11 +52,6 @@ import org.springframework.util.ClassUtils; * * Uses buffered writer to improve performance.
* - *

- * Output lines are buffered until {@link #flush()} is called and only then the - * actual writing to file occurs. - *

- * * The implementation is *not* thread-safe. * * @author Waseem Malik @@ -275,9 +269,6 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement } } - public void flush() throws FlushFailedException { - } - // Returns object representing state. private OutputState getOutputState() { if (state == null) { @@ -501,7 +492,4 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement } - public void clear() throws ClearFailedException { - } - } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemWriter.java deleted file mode 100644 index 1e508b2fd..000000000 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemWriter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2006-2008 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.item.support; - -import org.springframework.batch.item.ClearFailedException; -import org.springframework.batch.item.FlushFailedException; -import org.springframework.batch.item.ItemWriter; - -/** - * Abstract {@link ItemWriter}. - * - * @author Lucas Ward - */ -public abstract class AbstractItemWriter implements ItemWriter { - - public void flush() throws FlushFailedException { - } - - public void clear() throws ClearFailedException { - } -} diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java index c18364dba..b66912b87 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java @@ -13,7 +13,7 @@ import org.springframework.batch.item.ItemWriter; * @author Robert Kasanicky * @author Dave Syer */ -public class CompositeItemWriter extends AbstractItemWriter { +public class CompositeItemWriter implements ItemWriter { private List> delegates; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java index 00c647053..742dd7f7c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java @@ -19,7 +19,6 @@ import javax.xml.stream.XMLStreamException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.batch.item.ClearFailedException; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.FlushFailedException; import org.springframework.batch.item.ItemStream; @@ -42,9 +41,6 @@ import org.springframework.util.CollectionUtils; * This item writer also provides restart, statistics and transaction features * by implementing corresponding interfaces. * - * Output is buffered until {@link #flush()} is called - only then the actual - * writing to file takes place. - * * The implementation is *not* thread-safe. * * @author Peter Zozom @@ -463,16 +459,4 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen } - /** - * Writes buffered items to XML stream and marks restore point. - */ - public void flush() throws FlushFailedException { - } - - /** - * Clear the output buffer - */ - public void clear() throws ClearFailedException { - } - } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriterTests.java index 285858d7c..a62a9f424 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/BatchSqlUpdateItemWriterTests.java @@ -103,12 +103,6 @@ public class BatchSqlUpdateItemWriterTests extends TestCase { } } - /** - * Test method for - * {@link org.springframework.batch.item.database.BatchSqlUpdateItemWriter#flush()} - * . - * @throws Exception - */ public void testWriteAndFlush() throws Exception { ps.addBatch(); expectLastCall(); @@ -119,12 +113,6 @@ public class BatchSqlUpdateItemWriterTests extends TestCase { assertTrue(list.contains("SQL")); } - /** - * Test method for - * {@link org.springframework.batch.item.database.BatchSqlUpdateItemWriter#flush()} - * . - * @throws Exception - */ public void testWriteAndFlushWithEmptyUpdate() throws Exception { ps.addBatch(); expectLastCall(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateAwareItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateAwareItemWriterTests.java index 2d75aac69..d813f4a83 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateAwareItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateAwareItemWriterTests.java @@ -21,7 +21,7 @@ import java.util.List; import junit.framework.TestCase; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.repeat.support.RepeatSynchronizationManager; import org.springframework.dao.DataAccessException; import org.springframework.orm.hibernate3.HibernateTemplate; @@ -42,7 +42,7 @@ public class HibernateAwareItemWriterTests extends TestCase { }; } - private class StubItemWriter extends AbstractItemWriter { + private class StubItemWriter implements ItemWriter { public void write(List items) { list.addAll(items); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java index d048fafef..adcb811e2 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java @@ -16,6 +16,11 @@ package org.springframework.batch.item.file; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -24,14 +29,14 @@ import java.nio.charset.UnsupportedCharsetException; import java.util.Arrays; import java.util.Collections; -import junit.framework.TestCase; - +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemStreamException; import org.springframework.batch.item.file.transform.LineAggregator; import org.springframework.batch.item.file.transform.PassThroughLineAggregator; import org.springframework.core.io.FileSystemResource; -import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -44,7 +49,7 @@ import org.springframework.util.ClassUtils; * @author Dave Syer * */ -public class FlatFileItemWriterTests extends TestCase { +public class FlatFileItemWriterTests { // object under test private FlatFileItemWriter writer = new FlatFileItemWriter(); @@ -64,7 +69,8 @@ public class FlatFileItemWriterTests extends TestCase { * Create temporary output file, define mock behaviour, set dependencies and * initialize the object under test */ - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { outputFile = File.createTempFile("flatfile-test-output-", ".tmp"); @@ -78,7 +84,8 @@ public class FlatFileItemWriterTests extends TestCase { /** * Release resources and delete the temporary output file */ - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { if (reader != null) { reader.close(); } @@ -100,6 +107,7 @@ public class FlatFileItemWriterTests extends TestCase { return reader.readLine(); } + @Test public void testWriteWithMultipleOpen() throws Exception { writer.open(executionContext); @@ -110,6 +118,7 @@ public class FlatFileItemWriterTests extends TestCase { assertEquals("test2", readLine()); } + @Test public void testOpenTwice() { // opening the writer twice should cause no issues writer.open(executionContext); @@ -121,6 +130,7 @@ public class FlatFileItemWriterTests extends TestCase { * * @throws Exception */ + @Test public void testWriteString() throws Exception { writer.open(executionContext); writer.write(Collections.singletonList(TEST_STRING)); @@ -135,6 +145,7 @@ public class FlatFileItemWriterTests extends TestCase { * * @throws Exception */ + @Test public void testWriteWithConverter() throws Exception { writer.setLineAggregator(new LineAggregator() { public String aggregate(String item) { @@ -154,6 +165,7 @@ public class FlatFileItemWriterTests extends TestCase { * * @throws Exception */ + @Test public void testWriteWithConverterAndString() throws Exception { writer.setLineAggregator(new LineAggregator() { public String aggregate(String item) { @@ -171,6 +183,7 @@ public class FlatFileItemWriterTests extends TestCase { * * @throws Exception */ + @Test public void testWriteRecord() throws Exception { writer.open(executionContext); writer.write(Collections.singletonList("1")); @@ -178,6 +191,7 @@ public class FlatFileItemWriterTests extends TestCase { assertEquals("1", lineFromFile); } + @Test public void testWriteRecordWithrecordSeparator() throws Exception { writer.setLineSeparator("|"); writer.open(executionContext); @@ -186,6 +200,7 @@ public class FlatFileItemWriterTests extends TestCase { assertEquals("1|2|", lineFromFile); } + @Test public void testRestart() throws Exception { writer.open(executionContext); @@ -217,6 +232,7 @@ public class FlatFileItemWriterTests extends TestCase { } + @Test public void testOpenWithNonWritableFile() throws Exception { writer = new FlatFileItemWriter(); writer.setLineAggregator(new PassThroughLineAggregator()); @@ -237,6 +253,7 @@ public class FlatFileItemWriterTests extends TestCase { } } + @Test public void testAfterPropertiesSetChecksMandatory() throws Exception { writer = new FlatFileItemWriter(); try { @@ -248,6 +265,7 @@ public class FlatFileItemWriterTests extends TestCase { } } + @Test public void testDefaultStreamContext() throws Exception { writer = new FlatFileItemWriter(); writer.setResource(new FileSystemResource(outputFile)); @@ -261,6 +279,7 @@ public class FlatFileItemWriterTests extends TestCase { assertEquals(0, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".current.count")); } + @Test public void testWriteStringWithBogusEncoding() throws Exception { writer.setEncoding("BOGUS"); try { @@ -273,6 +292,7 @@ public class FlatFileItemWriterTests extends TestCase { writer.close(null); } + @Test public void testWriteStringWithEncodingAfterClose() throws Exception { testWriteStringWithBogusEncoding(); writer.setEncoding("UTF-8"); @@ -283,6 +303,7 @@ public class FlatFileItemWriterTests extends TestCase { assertEquals(TEST_STRING, lineFromFile); } + @Test public void testWriteHeader() throws Exception { writer.setHeaderLines(new String[] { "a", "b" }); writer.open(executionContext); @@ -296,6 +317,7 @@ public class FlatFileItemWriterTests extends TestCase { assertEquals(TEST_STRING, lineFromFile); } + @Test public void testWriteHeaderAfterRestartOnFirstChunk() throws Exception { writer.setHeaderLines(new String[] { "a", "b" }); writer.open(executionContext); @@ -314,6 +336,7 @@ public class FlatFileItemWriterTests extends TestCase { assertEquals(null, lineFromFile); } + @Test public void testWriteHeaderAfterRestartOnSecondChunk() throws Exception { writer.setHeaderLines(new String[] { "a", "b" }); writer.open(executionContext); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java index e36f578a8..611aa293a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java @@ -110,7 +110,6 @@ public class StaxEventItemWriterTests { writer.setHeaderItems(new Object[] {header1, header2}); writer.open(executionContext); writer.write(items); - writer.flush(); String content = outputFileContent(); assertTrue("Wrong content: "+content, content.contains((""))); assertTrue("Wrong content: "+content, content.contains((""))); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java index 6484c756e..c7d369d09 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java @@ -21,10 +21,10 @@ import java.util.List; import junit.framework.TestCase; import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.file.FlatFileItemReader; import org.springframework.batch.item.file.mapping.FieldSet; import org.springframework.batch.item.file.mapping.FieldSetMapper; -import org.springframework.batch.item.support.AbstractItemWriter; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -67,7 +67,7 @@ public abstract class AbstractTradeBatchTests extends TestCase { } } - protected static class TradeWriter extends AbstractItemWriter { + protected static class TradeWriter implements ItemWriter { int count = 0; // This has to be synchronized because we are going to test the state diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandler.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandler.java index 43f5775b3..233fd1fe5 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandler.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandler.java @@ -70,11 +70,9 @@ public class ItemWriterChunkHandler implements ChunkHandler { } } } - itemWriter.flush(); } catch (Exception e) { logger.debug("Failed chunk", e); - itemWriter.clear(); // TODO: need to force rollback as well return new ChunkResponse(ExitStatus.FAILED.addExitDescription(e.getClass().getName() + ": " + e.getMessage()), chunk.getJobId(), skipCount); diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/item/MessageChannelItemWriter.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/item/MessageChannelItemWriter.java index 29c8d6775..02e3ec745 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/item/MessageChannelItemWriter.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/item/MessageChannelItemWriter.java @@ -17,7 +17,7 @@ package org.springframework.batch.integration.item; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Required; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.message.GenericMessage; @@ -26,7 +26,7 @@ import org.springframework.integration.message.GenericMessage; * @author Dave Syer * */ -public class MessageChannelItemWriter extends AbstractItemWriter { +public class MessageChannelItemWriter implements ItemWriter { private MessageChannel channel; diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandlerTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandlerTests.java index 2c106f9ac..7a0f07ba3 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandlerTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ItemWriterChunkHandlerTests.java @@ -8,7 +8,7 @@ import org.junit.Test; import org.springframework.batch.core.SkipListener; import org.springframework.batch.core.listener.SkipListenerSupport; import org.springframework.batch.core.step.skip.AlwaysSkipItemSkipPolicy; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.repeat.ExitStatus; import org.springframework.util.StringUtils; @@ -28,7 +28,7 @@ public class ItemWriterChunkHandlerTests { @SuppressWarnings("unchecked") @Test public void testVanillaHandleChunk() { - handler.setItemWriter(new AbstractItemWriter() { + handler.setItemWriter(new ItemWriter() { public void write(List items) throws Exception { count+=items.size(); } @@ -44,7 +44,7 @@ public class ItemWriterChunkHandlerTests { @SuppressWarnings("unchecked") @Test public void testSetItemSkipPolicy() { - handler.setItemWriter(new AbstractItemWriter() { + handler.setItemWriter(new ItemWriter() { public void write(List items) throws Exception { count+=items.size(); throw new RuntimeException("Planned failure"); @@ -62,7 +62,7 @@ public class ItemWriterChunkHandlerTests { @SuppressWarnings("unchecked") @Test public void testRegisterSkipListener() { - handler.setItemWriter(new AbstractItemWriter() { + handler.setItemWriter(new ItemWriter() { public void write(List items) throws Exception { count+=items.size(); throw new RuntimeException("Planned failure"); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemWriter.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemWriter.java index 39a2272d4..c2e16a474 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemWriter.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemWriter.java @@ -4,11 +4,11 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.stereotype.Component; @Component -public class TestItemWriter extends AbstractItemWriter { +public class TestItemWriter implements ItemWriter { private static final Log logger = LogFactory.getLog(TestItemWriter.class); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/PlayerItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/PlayerItemWriter.java index 75d25228e..4e5d3b8b4 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/PlayerItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/PlayerItemWriter.java @@ -2,11 +2,11 @@ package org.springframework.batch.sample.domain.football.internal; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.football.Player; import org.springframework.batch.sample.domain.football.PlayerDao; -public class PlayerItemWriter extends AbstractItemWriter { +public class PlayerItemWriter implements ItemWriter { private PlayerDao playerDao; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java index 246dffa5b..c83838a87 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java @@ -20,12 +20,12 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.person.Person; -public class PersonWriter extends AbstractItemWriter { +public class PersonWriter implements ItemWriter { private static Log log = LogFactory.getLog(PersonWriter.class); public void write(List data) { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseWriter.java index 5841b4b81..a0de507f5 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseWriter.java @@ -3,7 +3,7 @@ package org.springframework.batch.sample.domain.trade.internal; import java.math.BigDecimal; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.trade.CustomerCredit; import org.springframework.batch.sample.domain.trade.CustomerCreditDao; @@ -12,7 +12,7 @@ import org.springframework.batch.sample.domain.trade.CustomerCreditDao; * * @author Robert Kasanicky */ -public class CustomerCreditIncreaseWriter extends AbstractItemWriter { +public class CustomerCreditIncreaseWriter implements ItemWriter { public static final BigDecimal FIXED_AMOUNT = new BigDecimal("1000"); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java index fe0a35a89..46586d438 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java @@ -18,11 +18,11 @@ package org.springframework.batch.sample.domain.trade.internal; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.trade.CustomerCredit; import org.springframework.batch.sample.domain.trade.CustomerCreditDao; -public class CustomerCreditUpdateWriter extends AbstractItemWriter { +public class CustomerCreditUpdateWriter implements ItemWriter { private double creditFilter = 800; private CustomerCreditDao dao; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateWriter.java index 4f0d4218d..7b6ebac72 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateWriter.java @@ -18,7 +18,7 @@ package org.springframework.batch.sample.domain.trade.internal; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.trade.CustomerDebit; import org.springframework.batch.sample.domain.trade.CustomerDebitDao; import org.springframework.batch.sample.domain.trade.Trade; @@ -29,7 +29,7 @@ import org.springframework.batch.sample.domain.trade.Trade; * * @author Robert Kasanicky */ -public class CustomerUpdateWriter extends AbstractItemWriter { +public class CustomerUpdateWriter implements ItemWriter { private CustomerDebitDao dao; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java index ee8c05529..83bde85ab 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java @@ -20,7 +20,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.batch.sample.domain.trade.TradeDao; @@ -28,7 +28,7 @@ import org.springframework.batch.sample.domain.trade.TradeDao; * Delegates the actual writing to custom DAO delegate. Allows configurable * exception raising for testing skip and restart. */ -public class TradeWriter extends AbstractItemWriter { +public class TradeWriter implements ItemWriter { private static Log log = LogFactory.getLog(TradeWriter.class); private TradeDao dao; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/DummyItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/DummyItemWriter.java index deaae2391..620c356aa 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/DummyItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/DummyItemWriter.java @@ -17,13 +17,13 @@ package org.springframework.batch.sample.support; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; /** * @author Dave Syer * */ -public class DummyItemWriter extends AbstractItemWriter { +public class DummyItemWriter implements ItemWriter { public void write(List item) throws Exception { // NO-OP diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java index b26c12425..95d6bfc7c 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java @@ -3,13 +3,13 @@ package org.springframework.batch.sample.support; import java.util.ArrayList; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.validator.ValidationException; /** * Remembers all items written - useful for testing. */ -public class ItemTrackingItemWriter extends AbstractItemWriter { +public class ItemTrackingItemWriter implements ItemWriter { private List items = new ArrayList(); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java index cfaa8a275..220f46cf4 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java @@ -2,7 +2,7 @@ package org.springframework.batch.sample.support; import java.util.List; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; /** * Simulates temporary output trouble - requires to retry 3 times to pass @@ -10,7 +10,7 @@ import org.springframework.batch.item.support.AbstractItemWriter; * * @author Robert Kasanicky */ -public class RetrySampleItemWriter extends AbstractItemWriter { +public class RetrySampleItemWriter implements ItemWriter { private int counter = 0; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java index 7ee51cd74..ad3d690a6 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; import org.junit.Test; -import org.springframework.batch.item.support.AbstractItemWriter; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; /** @@ -45,7 +45,7 @@ public class CustomItemWriterTests { assertEquals(3, itemWriter.getOutput().size()); } - public class CustomItemWriter extends AbstractItemWriter { + public class CustomItemWriter implements ItemWriter { List output = TransactionAwareProxyFactory.createTransactionalList();