* Listener interface for the writing of items. Implementations of this interface are
- * notified before, after, and in case of any exception thrown while writing a list of
+ * notified before, after, and in case of any exception thrown while writing a chunk of
* items.
*
*
@@ -42,19 +43,18 @@ import org.springframework.batch.item.ItemWriter;
public interface ItemWriteListener extends StepListener {
/**
- * Called before {@link ItemWriter#write(java.util.List)}
+ * Called before {@link ItemWriter#write(Chunk)}
* @param items to be written
*/
- default void beforeWrite(List extends S> items) {
+ default void beforeWrite(Chunk extends S> items) {
}
/**
- * Called after {@link ItemWriter#write(java.util.List)}. This is called before any
- * transaction is committed, and before
- * {@link ChunkListener#afterChunk(ChunkContext)}.
+ * Called after {@link ItemWriter#write(Chunk)}. This is called before any transaction
+ * is committed, and before {@link ChunkListener#afterChunk(ChunkContext)}.
* @param items written items
*/
- default void afterWrite(List extends S> items) {
+ default void afterWrite(Chunk extends S> items) {
}
/**
@@ -64,7 +64,7 @@ public interface ItemWriteListener extends StepListener {
* @param exception thrown from {@link ItemWriter}
* @param items attempted to be written.
*/
- default void onWriteError(Exception exception, List extends S> items) {
+ default void onWriteError(Exception exception, Chunk extends S> items) {
}
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/AfterWrite.java b/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/AfterWrite.java
index 9d8bda813..8a15a1739 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/AfterWrite.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/AfterWrite.java
@@ -27,12 +27,14 @@ import org.springframework.batch.item.ItemWriter;
/**
* Marks a method to be called after an item is passed to an {@link ItemWriter}. Note that
- * this annotation takes a {@link List} because Spring Batch generally processes a group
- * of items (for the sake of efficiency).
+ * this annotation takes a {@link org.springframework.batch.item.Chunk} because Spring
+ * Batch generally processes a group of items (for the sake of efficiency).
*
- * Expected signature: void afterWrite({@link List}<? extends S> items)
+ * Expected signature: void afterWrite({@link org.springframework.batch.item.Chunk}<?
+ * extends S> items)
*
* @author Lucas Ward
+ * @author Mahmoud Ben Hassine
* @since 2.0
* @see ItemWriteListener
*/
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/BeforeWrite.java b/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/BeforeWrite.java
index 7c5eb1ce8..58812a540 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/BeforeWrite.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/BeforeWrite.java
@@ -26,11 +26,13 @@ import org.springframework.batch.core.ItemWriteListener;
import org.springframework.batch.item.ItemWriter;
/**
- * Marks a method to be called before an item is passed to an {@link ItemWriter}.
+ * Marks a method to be called before a chunk is passed to an {@link ItemWriter}.
*
- * Expected signature: void beforeWrite({@link List}<? extends S> items)
+ * Expected signature: void beforeWrite({@link org.springframework.batch.item.Chunk}<?
+ * extends S> items)
*
* @author Lucas Ward
+ * @author Mahmoud Ben Hassine
* @since 2.0
* @see ItemWriteListener
*/
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/OnWriteError.java b/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/OnWriteError.java
index 7d8283ba0..fe71f0870 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/OnWriteError.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/annotation/OnWriteError.java
@@ -27,13 +27,14 @@ import org.springframework.batch.item.ItemWriter;
/**
* Marks a method to be called if an exception is thrown by an {@link ItemWriter}. Note
- * that this annotation takes a {@link List} because Spring Batch generally processes a
- * group of items (for the sake of efficiency).
+ * that this annotation takes a {@link org.springframework.batch.item.Chunk} because
+ * Spring Batch generally processes a group of items (for the sake of efficiency).
*
- * Expected signature: void onWriteError({@link Exception} exception, {@link List}<?
- * extends S> items)
+ * Expected signature: void onWriteError({@link Exception} exception,
+ * {@link org.springframework.batch.item.Chunk}<? extends S> items)
*
* @author Lucas Ward
+ * @author Mahmoud Ben Hassine
* @since 2.0
* @see ItemWriteListener
*/
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java
index de28c07e6..9c00e4ae5 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2013 the original author or authors.
+ * Copyright 2006-2022 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.
@@ -19,11 +19,13 @@ import java.util.Iterator;
import java.util.List;
import org.springframework.batch.core.ItemWriteListener;
+import org.springframework.batch.item.Chunk;
import org.springframework.core.Ordered;
/**
* @author Lucas Ward
* @author Dave Syer
+ * @author Mahmoud Ben Hassine
*
*/
public class CompositeItemWriteListener implements ItemWriteListener {
@@ -50,10 +52,10 @@ public class CompositeItemWriteListener implements ItemWriteListener {
/**
* Call the registered listeners in reverse order, respecting and prioritising those
* that implement {@link Ordered}.
- * @see ItemWriteListener#afterWrite(java.util.List)
+ * @see ItemWriteListener#afterWrite(Chunk)
*/
@Override
- public void afterWrite(List extends S> items) {
+ public void afterWrite(Chunk extends S> items) {
for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) {
ItemWriteListener super S> listener = iterator.next();
listener.afterWrite(items);
@@ -63,10 +65,10 @@ public class CompositeItemWriteListener implements ItemWriteListener {
/**
* Call the registered listeners in order, respecting and prioritising those that
* implement {@link Ordered}.
- * @see ItemWriteListener#beforeWrite(List)
+ * @see ItemWriteListener#beforeWrite(Chunk)
*/
@Override
- public void beforeWrite(List extends S> items) {
+ public void beforeWrite(Chunk extends S> items) {
for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) {
ItemWriteListener super S> listener = iterator.next();
listener.beforeWrite(items);
@@ -76,10 +78,10 @@ public class CompositeItemWriteListener implements ItemWriteListener {
/**
* Call the registered listeners in reverse order, respecting and prioritising those
* that implement {@link Ordered}.
- * @see ItemWriteListener#onWriteError(Exception, List)
+ * @see ItemWriteListener#onWriteError(Exception, Chunk)
*/
@Override
- public void onWriteError(Exception ex, List extends S> items) {
+ public void onWriteError(Exception ex, Chunk extends S> items) {
for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) {
ItemWriteListener super S> listener = iterator.next();
listener.onWriteError(ex, items);
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java
index 90170a4a7..fe517bebe 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2021 the original author or authors.
+ * Copyright 2006-2022 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.
@@ -28,6 +28,7 @@ import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.scope.context.ChunkContext;
+import org.springframework.batch.item.Chunk;
import org.springframework.batch.item.ItemStream;
import org.springframework.lang.Nullable;
@@ -241,10 +242,10 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch
}
/**
- * @see ItemWriteListener#afterWrite(List)
+ * @see ItemWriteListener#afterWrite(Chunk)
*/
@Override
- public void afterWrite(List extends S> items) {
+ public void afterWrite(Chunk extends S> items) {
try {
itemWriteListener.afterWrite(items);
}
@@ -254,10 +255,10 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch
}
/**
- * @see ItemWriteListener#beforeWrite(List)
+ * @see ItemWriteListener#beforeWrite(Chunk)
*/
@Override
- public void beforeWrite(List extends S> items) {
+ public void beforeWrite(Chunk extends S> items) {
try {
itemWriteListener.beforeWrite(items);
}
@@ -267,10 +268,10 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch
}
/**
- * @see ItemWriteListener#onWriteError(Exception, List)
+ * @see ItemWriteListener#onWriteError(Exception, Chunk)
*/
@Override
- public void onWriteError(Exception ex, List extends S> items) {
+ public void onWriteError(Exception ex, Chunk extends S> items) {
try {
itemWriteListener.onWriteError(ex, items);
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java
index df4b988a2..4ef713a61 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2022 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.
@@ -46,6 +46,7 @@ import org.springframework.batch.core.annotation.OnSkipInRead;
import org.springframework.batch.core.annotation.OnSkipInWrite;
import org.springframework.batch.core.annotation.OnWriteError;
import org.springframework.batch.core.scope.context.ChunkContext;
+import org.springframework.batch.item.Chunk;
/**
* Enumeration for {@link StepListener} meta data, which ties together the names of
@@ -72,10 +73,10 @@ public enum StepListenerMetaData implements ListenerMetaData {
Object.class),
ON_PROCESS_ERROR("onProcessError", "on-process-error-method", OnProcessError.class, ItemProcessListener.class,
Object.class, Exception.class),
- BEFORE_WRITE("beforeWrite", "before-write-method", BeforeWrite.class, ItemWriteListener.class, List.class),
- AFTER_WRITE("afterWrite", "after-write-method", AfterWrite.class, ItemWriteListener.class, List.class),
+ BEFORE_WRITE("beforeWrite", "before-write-method", BeforeWrite.class, ItemWriteListener.class, Chunk.class),
+ AFTER_WRITE("afterWrite", "after-write-method", AfterWrite.class, ItemWriteListener.class, Chunk.class),
ON_WRITE_ERROR("onWriteError", "on-write-error-method", OnWriteError.class, ItemWriteListener.class,
- Exception.class, List.class),
+ Exception.class, Chunk.class),
ON_SKIP_IN_READ("onSkipInRead", "on-skip-in-read-method", OnSkipInRead.class, SkipListener.class, Throwable.class),
ON_SKIP_IN_PROCESS("onSkipInProcess", "on-skip-in-process-method", OnSkipInProcess.class, SkipListener.class,
Object.class, Throwable.class),
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java
index 1a7fc7d0a..fbeb0425b 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2019 the original author or authors.
+ * Copyright 2006-2022 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.
@@ -21,6 +21,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
+import org.springframework.batch.item.Chunk;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.lang.Nullable;
@@ -28,6 +29,7 @@ import org.springframework.lang.Nullable;
* A {@link Tasklet} implementing variations on read-process-write item handling.
*
* @author Dave Syer
+ * @author Mahmoud Ben Hassine
* @param input item type
*/
public class ChunkOrientedTasklet implements Tasklet {
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProcessor.java
index 5ca36744d..3bab818b8 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProcessor.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2007 the original author or authors.
+ * Copyright 2006-2022 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.
@@ -17,9 +17,10 @@
package org.springframework.batch.core.step.item;
import org.springframework.batch.core.StepContribution;
+import org.springframework.batch.item.Chunk;
/**
- * Interface defined for processing {@link Chunk}s.
+ * Interface defined for processing {@link org.springframework.batch.item.Chunk}s.
*
* @since 2.0
*/
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProvider.java
index 36b778d2c..f713af61f 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProvider.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2007 the original author or authors.
+ * Copyright 2006-2022 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.
@@ -17,10 +17,11 @@
package org.springframework.batch.core.step.item;
import org.springframework.batch.core.StepContribution;
+import org.springframework.batch.item.Chunk;
/**
- * Interface for providing {@link Chunk}s to be processed, used by the
- * {@link ChunkOrientedTasklet}
+ * Interface for providing {@link org.springframework.batch.item.Chunk}s to be processed,
+ * used by the {@link ChunkOrientedTasklet}
*
* @since 2.0
* @see ChunkOrientedTasklet
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/DefaultItemFailureHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/DefaultItemFailureHandler.java
index 77c5c5225..d43dd1b20 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/DefaultItemFailureHandler.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/DefaultItemFailureHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2008 the original author or authors.
+ * Copyright 2006-2022 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.
@@ -20,6 +20,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.listener.ItemListenerSupport;
+import org.springframework.batch.item.Chunk;
/**
* Default implementation of the {@link ItemListenerSupport} class that writes all
@@ -28,6 +29,7 @@ import org.springframework.batch.core.listener.ItemListenerSupport;
* object.
*
* @author Lucas Ward
+ * @author Mahmoud Ben Hassine
*
*/
public class DefaultItemFailureHandler extends ItemListenerSupport