RESOLVED - issue BATCH-788: Remove flush/clear from ItemWriter
Done
This commit is contained in:
@@ -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<T>() {
|
||||
|
||||
public void write(List<? extends T> 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();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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<T, S> implements StepHandler {
|
||||
itemReader.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ClearFailedException
|
||||
*/
|
||||
public void clear() throws ClearFailedException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FlushFailedException
|
||||
*/
|
||||
public void flush() throws FlushFailedException {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<String> {
|
||||
private final class StubItemWriter implements ItemWriter<String> {
|
||||
private String values = "";
|
||||
|
||||
public void write(List<? extends String> items) throws Exception {
|
||||
|
||||
@@ -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<String> written = new ArrayList<String>();
|
||||
|
||||
private ItemWriter<String> writer = new AbstractItemWriter<String>() {
|
||||
private ItemWriter<String> writer = new ItemWriter<String>() {
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
written.addAll(data);
|
||||
}
|
||||
@@ -165,7 +164,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
*/
|
||||
SimpleStepFactoryBean<String,String> factory = getStepFactory(new String[] { "foo", "bar", "spam" });
|
||||
|
||||
factory.setItemWriter(new AbstractItemWriter<String>() {
|
||||
factory.setItemWriter(new ItemWriter<String>() {
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
throw new RuntimeException("Error!");
|
||||
}
|
||||
@@ -198,7 +197,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
public void testExceptionTerminates() throws Exception {
|
||||
SimpleStepFactoryBean<String,String> factory = getStepFactory(new String[] { "foo", "bar", "spam" });
|
||||
factory.setBeanName("exceptionStep");
|
||||
factory.setItemWriter(new AbstractItemWriter<String>() {
|
||||
factory.setItemWriter(new ItemWriter<String>() {
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
throw new RuntimeException("Foo");
|
||||
}
|
||||
@@ -222,7 +221,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
SimpleStepFactoryBean<String,String> factory = getStepFactory(new String[] { "foo", "bar", "spam" });
|
||||
factory.setBeanName("exceptionStep");
|
||||
factory.setExceptionHandler(new SimpleLimitExceptionHandler(1));
|
||||
factory.setItemWriter(new AbstractItemWriter<String>() {
|
||||
factory.setItemWriter(new ItemWriter<String>() {
|
||||
int count = 0;
|
||||
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
|
||||
@@ -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<Object> processor = new AbstractItemWriter<Object>() {
|
||||
private ItemWriter<Object> processor = new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> data) throws Exception {
|
||||
processed.addAll(data);
|
||||
}
|
||||
@@ -198,7 +197,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
|
||||
}
|
||||
};
|
||||
|
||||
ItemWriter<Object> itemWriter = new AbstractItemWriter<Object>() {
|
||||
ItemWriter<Object> itemWriter = new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> 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<Object> itemWriter = new AbstractItemWriter<Object>() {
|
||||
ItemWriter<Object> itemWriter = new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> 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<Object> itemWriter = new AbstractItemWriter<Object>() {
|
||||
ItemWriter<Object> itemWriter = new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> 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<Object> itemWriter = new AbstractItemWriter<Object>() {
|
||||
ItemWriter<Object> itemWriter = new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> item) throws Exception {
|
||||
logger.debug("Write Called! Item: [" + item + "]");
|
||||
throw new RuntimeException("Write error - planned but retryable.");
|
||||
|
||||
@@ -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<Object> itemWriter;
|
||||
private ItemWriter<Object> 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<Object>() {
|
||||
itemWriter = new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> item) throws Exception {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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<String>(getReader(new String[] { "a", "b", "c" }),
|
||||
new AbstractItemWriter<String>() {
|
||||
new ItemWriter<String>() {
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
TransactionSynchronizationManager
|
||||
.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
|
||||
@@ -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<Serializable> list = new ArrayList<Serializable>();
|
||||
|
||||
ItemWriter<String> itemWriter = new AbstractItemWriter<String>() {
|
||||
ItemWriter<String> itemWriter = new ItemWriter<String>() {
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
processed.addAll(data);
|
||||
}
|
||||
|
||||
@@ -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<Object> writer = new AbstractItemWriter<Object>() {
|
||||
final ItemWriter<Object> writer = new ItemWriter<Object>() {
|
||||
public void write(final List<? extends Object> texts) {
|
||||
|
||||
for (Object text : texts) {
|
||||
|
||||
@@ -27,11 +27,10 @@ import java.util.List;
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
* @author Dave Syer
|
||||
@@ -40,33 +39,12 @@ import java.util.List;
|
||||
public interface ItemWriter<T> {
|
||||
|
||||
/**
|
||||
* 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<? extends T> 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;
|
||||
}
|
||||
|
||||
@@ -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<T> extends AbstractMethodInvokingDelegator<T> 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 {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T> extends AbstractMethodInv
|
||||
this.fieldsUsedAsTargetMethodArguments = fieldsUsedAsMethodArguments;
|
||||
}
|
||||
|
||||
public void clear() throws ClearFailedException {
|
||||
}
|
||||
|
||||
public void flush() throws FlushFailedException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> extends AbstractItemWriter<T> implements InitializingBean {
|
||||
public class BatchSqlUpdateItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
|
||||
private JdbcOperations jdbcTemplate;
|
||||
|
||||
|
||||
@@ -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.<br/>
|
||||
*
|
||||
* 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.<br/>
|
||||
* to do the actual writing of the item.<br/><br/>
|
||||
*
|
||||
* 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<T> extends AbstractItemWriter<T> implements InitializingBean {
|
||||
public class HibernateAwareItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
|
||||
private ItemWriter<? super T> delegate;
|
||||
|
||||
|
||||
@@ -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<T> extends AbstractItemWriter<T> implements InitializingBean {
|
||||
public class JpaAwareItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
|
||||
private ItemWriter<? super T> delegate;
|
||||
|
||||
|
||||
@@ -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.<br/>
|
||||
*
|
||||
* <p>
|
||||
* Output lines are buffered until {@link #flush()} is called and only then the
|
||||
* actual writing to file occurs.
|
||||
* </p>
|
||||
*
|
||||
* The implementation is *not* thread-safe.
|
||||
*
|
||||
* @author Waseem Malik
|
||||
@@ -275,9 +269,6 @@ public class FlatFileItemWriter<T> 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<T> extends ExecutionContextUserSupport implement
|
||||
|
||||
}
|
||||
|
||||
public void clear() throws ClearFailedException {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<T> implements ItemWriter<T> {
|
||||
|
||||
public void flush() throws FlushFailedException {
|
||||
}
|
||||
|
||||
public void clear() throws ClearFailedException {
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
* @author Robert Kasanicky
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class CompositeItemWriter<T> extends AbstractItemWriter<T> {
|
||||
public class CompositeItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
private List<ItemWriter<? super T>> delegates;
|
||||
|
||||
|
||||
@@ -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<T> 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 {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<Object> {
|
||||
private class StubItemWriter implements ItemWriter<Object> {
|
||||
public void write(List<? extends Object> items) {
|
||||
list.addAll(items);
|
||||
}
|
||||
|
||||
@@ -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<String> writer = new FlatFileItemWriter<String>();
|
||||
@@ -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<String>() {
|
||||
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<String>() {
|
||||
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<String>();
|
||||
writer.setLineAggregator(new PassThroughLineAggregator<String>());
|
||||
@@ -237,6 +253,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterPropertiesSetChecksMandatory() throws Exception {
|
||||
writer = new FlatFileItemWriter<String>();
|
||||
try {
|
||||
@@ -248,6 +265,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultStreamContext() throws Exception {
|
||||
writer = new FlatFileItemWriter<String>();
|
||||
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);
|
||||
|
||||
@@ -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(("<!--" + header1 + "-->")));
|
||||
assertTrue("Wrong content: "+content, content.contains(("<!--" + header2 + "-->")));
|
||||
|
||||
@@ -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<Trade> {
|
||||
protected static class TradeWriter implements ItemWriter<Trade> {
|
||||
int count = 0;
|
||||
|
||||
// This has to be synchronized because we are going to test the state
|
||||
|
||||
@@ -70,11 +70,9 @@ public class ItemWriterChunkHandler<T> implements ChunkHandler<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -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<T> extends AbstractItemWriter<T> {
|
||||
public class MessageChannelItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
private MessageChannel channel;
|
||||
|
||||
|
||||
@@ -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<Object>() {
|
||||
handler.setItemWriter(new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> items) throws Exception {
|
||||
count+=items.size();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class ItemWriterChunkHandlerTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSetItemSkipPolicy() {
|
||||
handler.setItemWriter(new AbstractItemWriter<Object>() {
|
||||
handler.setItemWriter(new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> 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<Object>() {
|
||||
handler.setItemWriter(new ItemWriter<Object>() {
|
||||
public void write(List<? extends Object> items) throws Exception {
|
||||
count+=items.size();
|
||||
throw new RuntimeException("Planned failure");
|
||||
|
||||
@@ -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<T> extends AbstractItemWriter<T> {
|
||||
public class TestItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(TestItemWriter.class);
|
||||
|
||||
|
||||
@@ -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<Player> {
|
||||
public class PlayerItemWriter implements ItemWriter<Player> {
|
||||
|
||||
private PlayerDao playerDao;
|
||||
|
||||
|
||||
@@ -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<Person> {
|
||||
public class PersonWriter implements ItemWriter<Person> {
|
||||
private static Log log = LogFactory.getLog(PersonWriter.class);
|
||||
|
||||
public void write(List<? extends Person> data) {
|
||||
|
||||
@@ -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<CustomerCredit> {
|
||||
public class CustomerCreditIncreaseWriter implements ItemWriter<CustomerCredit> {
|
||||
|
||||
public static final BigDecimal FIXED_AMOUNT = new BigDecimal("1000");
|
||||
|
||||
|
||||
@@ -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<CustomerCredit> {
|
||||
public class CustomerCreditUpdateWriter implements ItemWriter<CustomerCredit> {
|
||||
private double creditFilter = 800;
|
||||
|
||||
private CustomerCreditDao dao;
|
||||
|
||||
@@ -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<Trade> {
|
||||
public class CustomerUpdateWriter implements ItemWriter<Trade> {
|
||||
|
||||
private CustomerDebitDao dao;
|
||||
|
||||
|
||||
@@ -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<Trade> {
|
||||
public class TradeWriter implements ItemWriter<Trade> {
|
||||
private static Log log = LogFactory.getLog(TradeWriter.class);
|
||||
|
||||
private TradeDao dao;
|
||||
|
||||
@@ -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<Object> {
|
||||
public class DummyItemWriter implements ItemWriter<Object> {
|
||||
|
||||
public void write(List<? extends Object> item) throws Exception {
|
||||
// NO-OP
|
||||
|
||||
@@ -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<T> extends AbstractItemWriter<T> {
|
||||
public class ItemTrackingItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
private List<T> items = new ArrayList<T>();
|
||||
|
||||
|
||||
@@ -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<T> extends AbstractItemWriter<T> {
|
||||
public class RetrySampleItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
private int counter = 0;
|
||||
|
||||
|
||||
@@ -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<T> extends AbstractItemWriter<T> {
|
||||
public class CustomItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
List<T> output = TransactionAwareProxyFactory.createTransactionalList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user