diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java
index 712a55313..f219b6d83 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java
@@ -17,6 +17,8 @@ package org.springframework.batch.core.scope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.core.scope.util.PlaceholderProxyFactoryBean;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeansException;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/ChunkContext.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/ChunkContext.java
similarity index 74%
rename from spring-batch-core/src/main/java/org/springframework/batch/core/scope/ChunkContext.java
rename to spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/ChunkContext.java
index ead7c8ff0..fa73f1410 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/ChunkContext.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/ChunkContext.java
@@ -1,4 +1,4 @@
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import org.springframework.core.AttributeAccessorSupport;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepContext.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContext.java
similarity index 95%
rename from spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepContext.java
rename to spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContext.java
index 609a3be51..067be85ee 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepContext.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContext.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import java.util.ArrayList;
import java.util.Collections;
@@ -28,6 +28,7 @@ import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.UnexpectedJobExecutionException;
+import org.springframework.batch.core.scope.StepScope;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.context.SynchronizedAttributeAccessor;
import org.springframework.util.Assert;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepContextRepeatCallback.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java
similarity index 98%
rename from spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepContextRepeatCallback.java
rename to spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java
index e55bcf607..dac072589 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepContextRepeatCallback.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScopeManager.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepScopeManager.java
similarity index 91%
rename from spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScopeManager.java
rename to spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepScopeManager.java
index 2447b2c91..28caa6944 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScopeManager.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepScopeManager.java
@@ -1,4 +1,4 @@
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepSynchronizationManager.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepSynchronizationManager.java
similarity index 95%
rename from spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepSynchronizationManager.java
rename to spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepSynchronizationManager.java
index 9d21f1e80..7f3a4a59e 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepSynchronizationManager.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepSynchronizationManager.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import java.util.Stack;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java
index f3cf838d1..890252d33 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java
@@ -1,7 +1,7 @@
package org.springframework.batch.core.scope.util;
-import org.springframework.batch.core.scope.StepContext;
-import org.springframework.batch.core.scope.StepSynchronizationManager;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
/**
* Implementation of {@link ContextFactory} that provides the current
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java
index 84e3b0365..f81f54e19 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java
@@ -32,7 +32,7 @@ import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.launch.support.ExitCodeMapper;
import org.springframework.batch.core.listener.CompositeStepExecutionListener;
import org.springframework.batch.core.repository.JobRepository;
-import org.springframework.batch.core.scope.StepSynchronizationManager;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java
index a646e9187..794c58a08 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java
@@ -25,8 +25,8 @@ import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.repository.JobRepository;
-import org.springframework.batch.core.scope.StepContext;
-import org.springframework.batch.core.scope.StepContextRepeatCallback;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepContextRepeatCallback;
import org.springframework.batch.core.step.AbstractStep;
import org.springframework.batch.core.step.StepInterruptionPolicy;
import org.springframework.batch.core.step.ThreadStepInterruptionPolicy;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java
index 1a0f77b61..73ec96ca0 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java
@@ -15,6 +15,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeIntegrationTests.java
index 353c40bcc..773cba66e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeIntegrationTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeIntegrationTests.java
@@ -12,6 +12,7 @@ import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java
index fb1440cda..a526767bf 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java
@@ -8,6 +8,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java
index 13fc6288a..59030d17c 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java
@@ -30,6 +30,8 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.context.support.StaticApplicationContext;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java
index 51f8ae046..11c42d921 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java
@@ -3,6 +3,8 @@ package org.springframework.batch.core.scope;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
public class TestStep implements Step {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepContextRepeatCallbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextRepeatCallbackTests.java
similarity index 90%
rename from spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepContextRepeatCallbackTests.java
rename to spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextRepeatCallbackTests.java
index 54200290c..9d8966e61 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepContextRepeatCallbackTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextRepeatCallbackTests.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -24,6 +24,9 @@ import org.junit.Test;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepContextRepeatCallback;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatStatus;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java
similarity index 94%
rename from spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepContextTests.java
rename to spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java
index 7e0f70466..d1286340e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepContextTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -30,6 +30,7 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepContext;
import org.springframework.batch.item.ExecutionContext;
/**
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepSynchronizationManagerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java
similarity index 89%
rename from spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepSynchronizationManagerTests.java
rename to spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java
index 95e8d29b9..7ca3d639e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepSynchronizationManagerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java
@@ -1,4 +1,4 @@
-package org.springframework.batch.core.scope;
+package org.springframework.batch.core.scope.context;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -12,6 +12,8 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
public class StepSynchronizationManagerTests {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/StepContextFactoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/StepContextFactoryTests.java
index 555baa7ca..dc1a9942e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/StepContextFactoryTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/StepContextFactoryTests.java
@@ -7,8 +7,8 @@ import org.junit.After;
import org.junit.Test;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
-import org.springframework.batch.core.scope.StepContext;
-import org.springframework.batch.core.scope.StepSynchronizationManager;
+import org.springframework.batch.core.scope.context.StepContext;
+import org.springframework.batch.core.scope.context.StepSynchronizationManager;
public class StepContextFactoryTests {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTaskletTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTaskletTests.java
index a94bfd95a..5ef6876c3 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTaskletTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTaskletTests.java
@@ -31,7 +31,7 @@ import org.junit.Test;
import org.springframework.batch.core.SkipListener;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
-import org.springframework.batch.core.scope.ChunkContext;
+import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.skip.NeverSkipItemSkipPolicy;
import org.springframework.batch.core.step.skip.SkipPolicy;
import org.springframework.batch.core.step.skip.SkipLimitExceededException;
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeDestructionCallbackIntegrationTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeDestructionCallbackIntegrationTests-context.xml
index 1dee023f0..039312d0d 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeDestructionCallbackIntegrationTests-context.xml
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeDestructionCallbackIntegrationTests-context.xml
@@ -43,7 +43,7 @@
-
+
\ No newline at end of file
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeIntegrationTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeIntegrationTests-context.xml
index 138af872c..25b79972a 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeIntegrationTests-context.xml
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeIntegrationTests-context.xml
@@ -38,7 +38,7 @@
-
+
\ No newline at end of file
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeNestedIntegrationTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeNestedIntegrationTests-context.xml
index b168b1a07..b34c64ad0 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeNestedIntegrationTests-context.xml
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeNestedIntegrationTests-context.xml
@@ -27,7 +27,7 @@
-
+
\ No newline at end of file
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeStartupIntegrationTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeStartupIntegrationTests-context.xml
index 8d7bc6089..87d44d972 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeStartupIntegrationTests-context.xml
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/StepScopeStartupIntegrationTests-context.xml
@@ -25,7 +25,7 @@
-
+
\ No newline at end of file
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/context/RetryContextSupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/context/RetryContextSupport.java
index 0795c36eb..c67765dbe 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/context/RetryContextSupport.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/context/RetryContextSupport.java
@@ -74,5 +74,10 @@ public class RetryContextSupport extends AttributeAccessorSupport implements Ret
if (throwable != null)
count++;
}
+
+ @Override
+ public String toString() {
+ return String.format("[RetryContext: count=%d, lastException=%s, exhausted=%b]", count, lastException, terminate);
+ }
}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/DefaultRetryState.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/DefaultRetryState.java
index 7924a4bb7..841ea08a1 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/DefaultRetryState.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/DefaultRetryState.java
@@ -104,4 +104,8 @@ public class DefaultRetryState implements RetryState {
return rollbackClassifier.classify(exception);
}
+ @Override
+ public String toString() {
+ return String.format("[%s: key=%s, forceRefresh=%b]", getClass().getSimpleName(), key, forceRefresh);
+ }
}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java
index 621e4c192..4f984f68c 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java
@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.retry.ExhaustedRetryException;
-import org.springframework.batch.retry.RetryState;
import org.springframework.batch.retry.RecoveryCallback;
import org.springframework.batch.retry.RetryCallback;
import org.springframework.batch.retry.RetryContext;
@@ -31,6 +30,7 @@ import org.springframework.batch.retry.RetryException;
import org.springframework.batch.retry.RetryListener;
import org.springframework.batch.retry.RetryOperations;
import org.springframework.batch.retry.RetryPolicy;
+import org.springframework.batch.retry.RetryState;
import org.springframework.batch.retry.TerminatedRetryException;
import org.springframework.batch.retry.backoff.BackOffContext;
import org.springframework.batch.retry.backoff.BackOffInterruptedException;
@@ -42,9 +42,10 @@ import org.springframework.batch.retry.policy.SimpleRetryPolicy;
/**
* Template class that simplifies the execution of operations with retry
- * semantics.
Retryable operations are encapsulated in implementations of
- * the {@link RetryCallback} interface and are executed using one of the
- * supplied execute methods.
+ * semantics.
+ * Retryable operations are encapsulated in implementations of the
+ * {@link RetryCallback} interface and are executed using one of the supplied
+ * execute methods.
*
* By default, an operation is retried if is throws any {@link Exception} or
* subclass of {@link Exception}. This behaviour can be changed by using the
@@ -130,7 +131,7 @@ public class RetryTemplate implements RetryOperations {
* dictates that we stop, in which case the most recent exception thrown by
* the callback will be rethrown.
*
- * @see org.springframework.batch.retry.RetryOperations#execute(org.springframework.batch.retry.RetryCallback)
+ * @see RetryOperations#execute(RetryCallback)
*
* @throws TerminatedRetryException if the retry has been manually
* terminated by a listener.
@@ -144,8 +145,7 @@ public class RetryTemplate implements RetryOperations {
* dictates that we stop, in which case the recovery callback will be
* executed.
*
- * @see org.springframework.batch.retry.RetryOperations#execute(org.springframework.batch.retry.RetryCallback,
- * org.springframework.batch.retry.RecoveryCallback)
+ * @see RetryOperations#execute(RetryCallback, RecoveryCallback)
*
* @throws TerminatedRetryException if the retry has been manually
* terminated by a listener.
@@ -156,10 +156,10 @@ public class RetryTemplate implements RetryOperations {
/**
* Execute the callback once if the policy dictates that we can, re-throwing
- * any exception encountered.
+ * any exception encountered so that clients can re-present the same task
+ * later.
*
- * @see org.springframework.batch.retry.RetryOperations#execute(RetryCallback,
- * RetryState)
+ * @see RetryOperations#execute(RetryCallback, RetryState)
*
* @throws ExhaustedRetryException if the retry has been exhausted.
*/
@@ -170,10 +170,10 @@ public class RetryTemplate implements RetryOperations {
/**
* Execute the callback once if the policy dictates that we can, re-throwing
- * any exception encountered.
+ * any exception encountered so that clients can re-present the same task
+ * later.
*
- * @see org.springframework.batch.retry.RetryOperations#execute(RetryCallback,
- * RetryState)
+ * @see RetryOperations#execute(RetryCallback, RetryState)
*/
public final T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback,
RetryState retryState) throws Exception, ExhaustedRetryException {
@@ -184,8 +184,7 @@ public class RetryTemplate implements RetryOperations {
* Execute the callback once if the policy dictates that we can, otherwise
* execute the recovery callback.
*
- * @see org.springframework.batch.retry.RetryOperations#execute(RetryCallback,
- * RecoveryCallback, RetryState)
+ * @see RetryOperations#execute(RetryCallback, RecoveryCallback, RetryState)
* @throws ExhaustedRetryException if the retry has been exhausted.
*/
protected T doExecute(RetryCallback retryCallback, RecoveryCallback recoveryCallback, RetryState state)
@@ -221,7 +220,7 @@ public class RetryTemplate implements RetryOperations {
* external retry to allow a recovery in handleRetryExhausted
* without the callback processing (which would throw an exception).
*/
- while (retryPolicy.canRetry(context) && !context.isExhaustedOnly()) {
+ while (canRetry(retryPolicy, context) && !context.isExhaustedOnly()) {
try {
logger.debug("Retry: count=" + context.getRetryCount());
@@ -257,9 +256,9 @@ public class RetryTemplate implements RetryOperations {
}
/*
- * A stateful policy that can retry should have rethrown the
+ * A stateful attempt that can retry should have rethrown the
* exception by now - i.e. we shouldn't get this far for a
- * stateful policy if it can retry.
+ * stateful attempt if it can retry.
*/
}
@@ -281,6 +280,19 @@ public class RetryTemplate implements RetryOperations {
}
+ /**
+ * Decide whether to proceed with the ongoing retry attempt. This method is
+ * called before the {@link RetryCallback} is executed, but after the
+ * backoff and open interceptors.
+ *
+ * @param retryPolicy the policy to apply
+ * @param context the current retry context
+ * @return true if we can continue with the attempt
+ */
+ protected boolean canRetry(RetryPolicy retryPolicy, RetryContext context) {
+ return retryPolicy.canRetry(context);
+ }
+
/**
* Clean up the cache if necessary and close the context provided (if the
* flag indicates that processing was successful).