BATCH-711:Modified ItemWriter interface to use parameterized types. Updated a portion of classes using ItemWriter as well.
This commit is contained in:
@@ -35,7 +35,7 @@ package org.springframework.batch.item;
|
||||
* @author Dave Syer
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public interface ItemWriter {
|
||||
public interface ItemWriter<T> {
|
||||
|
||||
/**
|
||||
* Process the supplied data element. Will be called multiple times during a
|
||||
@@ -46,7 +46,7 @@ public interface ItemWriter {
|
||||
* retry or a batch the framework will catch the exception and convert or
|
||||
* rethrow it as appropriate.
|
||||
*/
|
||||
void write(Object item) throws Exception;
|
||||
void write(T item) throws Exception;
|
||||
|
||||
/**
|
||||
* Flush any buffers that are being held. This will usually be performed
|
||||
|
||||
@@ -29,9 +29,9 @@ import org.springframework.batch.item.ItemWriter;
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class ItemWriterAdapter extends AbstractMethodInvokingDelegator<Object> implements ItemWriter {
|
||||
public class ItemWriterAdapter<T> extends AbstractMethodInvokingDelegator<T> implements ItemWriter<T> {
|
||||
|
||||
public void write(Object item) throws Exception {
|
||||
public void write(T item) throws Exception {
|
||||
invokeDelegateMethodWithArgument(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInvokingDelegator<Object> implements ItemWriter {
|
||||
public class PropertyExtractingDelegatingItemWriter<T> extends AbstractMethodInvokingDelegator<T> implements ItemWriter<T> {
|
||||
|
||||
private String[] fieldsUsedAsTargetMethodArguments;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInvoki
|
||||
* Extracts values from item's fields named in fieldsUsedAsTargetMethodArguments
|
||||
* and passes them as arguments to the delegate method.
|
||||
*/
|
||||
public void write(Object item) throws Exception {
|
||||
public void write(T item) throws Exception {
|
||||
// helper for extracting property values from a bean
|
||||
BeanWrapper beanWrapper = new BeanWrapperImpl(item);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Robert Kasanicky
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class HibernateCursorItemReader extends AbstractBufferedItemReaderItemStream implements ItemStream,
|
||||
public class HibernateCursorItemReader<T> extends AbstractBufferedItemReaderItemStream<T> implements ItemStream,
|
||||
InitializingBean {
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
@@ -150,7 +150,8 @@ public class HibernateCursorItemReader extends AbstractBufferedItemReaderItemStr
|
||||
this.fetchSize = fetchSize;
|
||||
}
|
||||
|
||||
protected Object doRead() throws Exception {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected T doRead() throws Exception {
|
||||
if (cursor.next()) {
|
||||
Object[] data = cursor.get();
|
||||
Object item;
|
||||
@@ -162,7 +163,7 @@ public class HibernateCursorItemReader extends AbstractBufferedItemReaderItemStr
|
||||
item = data[0];
|
||||
}
|
||||
|
||||
return item;
|
||||
return (T)item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ import org.springframework.batch.item.ItemWriter;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractItemStreamItemWriter extends ItemStreamSupport implements ItemWriter {
|
||||
public abstract class AbstractItemStreamItemWriter<T> extends ItemStreamSupport implements ItemWriter<T> {
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public abstract class AbstractItemWriter implements ItemWriter {
|
||||
public abstract class AbstractItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
public void flush() throws FlushFailedException {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user