From 6eb888313980684a94b679eb4ee455881ff46ec3 Mon Sep 17 00:00:00 2001
From: lucasward
Date: Wed, 27 Feb 2008 03:27:39 +0000
Subject: [PATCH] BATCH-392:removed saveExecutionContext from step (it's
handled at a lower level now)
---
.../support/CommandLineJobRunner.java | 7 +-
.../JobRegistryBeanPostProcessor.java | 7 +-
.../batch/execution/job/AbstractJob.java | 139 +++++++++++++++++
.../execution/job/{simple => }/SimpleJob.java | 5 +-
.../batch/execution/job/simple/package.html | 7 -
.../batch/execution/launch/JobLauncher.java | 3 +-
.../execution/launch/SimpleJobLauncher.java | 5 +-
.../repository/SimpleJobRepository.java | 7 +-
.../batch/execution/step/AbstractStep.java | 64 +++++++-
.../execution/step/ItemOrientedStep.java | 2 +-
.../batch/execution/step/TaskletStep.java | 63 +++++++-
.../SimpleExportedJobLauncherTests.java | 4 +-
.../JobRegistryBeanPostProcessorTests.java | 2 +-
.../configuration/MapJobRegistryTests.java | 4 +-
.../batch/execution/job/AbstractJobTests.java | 115 ++++++++++++++
.../batch/execution/job/JobSupport.java | 146 ++++++++++++++++++
.../job/{simple => }/SimpleJobTests.java | 3 +-
.../launch/SimpleJobLauncherTests.java | 2 +-
.../execution/launch/SimpleJobTests.java | 2 +-
.../SimpleJobRepositoryIntegrationTests.java | 2 +-
.../repository/SimpleJobRepositoryTests.java | 4 +-
.../repository/dao/AbstractJobDaoTests.java | 2 +-
.../repository/dao/AbstractStepDaoTests.java | 4 +-
.../repository/dao/JdbcJobDaoQueryTests.java | 2 +-
.../dao/JdbcStepDaoPrefixTests.java | 4 +-
.../repository/dao/MapJobDaoTests.java | 2 +-
.../repository/dao/MapStepDaoTests.java | 4 +-
.../BatchResourceFactoryBeanTests.java | 4 +-
.../scope/SimpleStepContextTests.java | 2 +-
.../batch/execution/scope/StepScopeTests.java | 4 +-
.../execution/step/ItemOrientedStepTests.java | 7 +-
.../batch/execution/step/StepSupport.java | 117 ++++++++++++++
.../execution/step/TaskletStepTests.java | 3 +-
.../StepExecutorInterruptionTests.java | 2 +-
.../src/test/resources/job-configuration.xml | 2 +-
.../batch/execution/bootstrap/support/job.xml | 2 +-
.../execution/configuration/test-context.xml | 10 +-
.../resources/simple-container-definition.xml | 3 +-
38 files changed, 691 insertions(+), 76 deletions(-)
create mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java
rename spring-batch-execution/src/main/java/org/springframework/batch/execution/job/{simple => }/SimpleJob.java (97%)
delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/package.html
create mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/job/AbstractJobTests.java
create mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java
rename spring-batch-execution/src/test/java/org/springframework/batch/execution/job/{simple => }/SimpleJobTests.java (98%)
create mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java
index abb738329..ad313b091 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java
@@ -20,7 +20,6 @@ import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.domain.Job;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobParameters;
import org.springframework.batch.core.repository.JobLocator;
@@ -81,7 +80,7 @@ import org.springframework.util.StringUtils;
*
*
*
- * - jobPath: the xml application context containing a {@link JobSupport}
+ *
- jobPath: the xml application context containing a {@link Job}
*
- jobName: the bean id of the job.
*
- jobLauncherPath: the xml application context containing a
* {@link JobLauncher}
@@ -107,7 +106,7 @@ import org.springframework.util.StringUtils;
* none is contained in the bean factory (it searches by type) then a
* {@link BeanDefinitionStoreException} will be thrown. The same exception will also
* be thrown if there is more than one present. Assuming the JobLauncher has been
- * set correctly, the jobName argument will be used to obtain an actual {@link JobSupport}.
+ * set correctly, the jobName argument will be used to obtain an actual {@link Job}.
* If a {@link JobLocator} has been set, then it will be used, if not the beanFactory
* will be asked, using the jobName as the bean id.
*
@@ -231,7 +230,7 @@ public class CommandLineJobRunner {
*
*
* - jobPath: the xml application context containing a
- * {@link JobSupport}
+ * {@link Job}
*
- jobName: the bean id of the job.
*
- jobLauncherPath: the xml application context containing a
* {@link JobLauncher}
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessor.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessor.java
index 09889d4ac..4d562881b 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessor.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessor.java
@@ -20,7 +20,6 @@ import java.util.HashSet;
import java.util.Iterator;
import org.springframework.batch.core.domain.Job;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.repository.DuplicateJobException;
import org.springframework.batch.core.repository.JobLocator;
import org.springframework.batch.core.repository.JobRegistry;
@@ -32,7 +31,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.util.Assert;
/**
- * A {@link BeanPostProcessor} that registers {@link JobSupport} beans
+ * A {@link BeanPostProcessor} that registers {@link Job} beans
* with a {@link JobRegistry}. Include a bean of this type along
* with your job configuration, and use the same
* {@link JobRegistry} as a {@link JobLocator} when
@@ -67,7 +66,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, Initiali
}
/**
- * De-register all the {@link JobSupport} instances that were
+ * De-register all the {@link Job} instances that were
* regsistered by this post processor.
* @see org.springframework.beans.factory.DisposableBean#destroy()
*/
@@ -80,7 +79,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, Initiali
}
/**
- * If the bean is an instance of {@link JobSupport} then register it.
+ * If the bean is an instance of {@link Job} then register it.
* @throws FatalBeanException if there is a
* {@link DuplicateJobException}.
*
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java
new file mode 100644
index 000000000..21ef40067
--- /dev/null
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2006-2007 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.execution.job;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.batch.core.domain.Job;
+import org.springframework.batch.core.domain.JobExecution;
+import org.springframework.batch.core.domain.Step;
+import org.springframework.batch.io.exception.BatchCriticalException;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.util.ClassUtils;
+
+/**
+ * Batch domain object representing a job. Job is an explicit abstraction
+ * representing the configuration of a job specified by a developer. It should
+ * be noted that restart policy is applied to the job as a whole and not to a
+ * step.
+ *
+ * @author Lucas Ward
+ * @author Dave Syer
+ */
+public abstract class AbstractJob implements BeanNameAware, Job {
+
+ private List steps = new ArrayList();
+
+ private String name;
+
+ private boolean restartable = false;
+
+ private int startLimit = Integer.MAX_VALUE;
+
+ /**
+ * Default constructor.
+ */
+ public AbstractJob() {
+ super();
+ }
+
+ /**
+ * Convenience constructor to immediately add name (which is mandatory but
+ * not final).
+ *
+ * @param name
+ */
+ public AbstractJob(String name) {
+ super();
+ this.name = name;
+ }
+
+ /**
+ * Set the name property if it is not already set. Because of the order of
+ * the callbacks in a Spring container the name property will be set first
+ * if it is present. Care is needed with bean definition inheritance - if a
+ * parent bean has a name, then its children need an explicit name as well,
+ * otherwise they will not be unique.
+ *
+ * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
+ */
+ public void setBeanName(String name) {
+ if (this.name == null) {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Set the name property. Always overrides the default value if this object
+ * is a Spring bean.
+ *
+ * @see #setBeanName(java.lang.String)
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#getSteps()
+ */
+ public List getSteps() {
+ return steps;
+ }
+
+ public void setSteps(List steps) {
+ this.steps.clear();
+ this.steps.addAll(steps);
+ }
+
+ public void addStep(Step step) {
+ this.steps.add(step);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#getStartLimit()
+ */
+ public int getStartLimit() {
+ return startLimit;
+ }
+
+ public void setStartLimit(int startLimit) {
+ this.startLimit = startLimit;
+ }
+
+ public void setRestartable(boolean restartable) {
+ this.restartable = restartable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#isRestartable()
+ */
+ public boolean isRestartable() {
+ return restartable;
+ }
+
+ public String toString() {
+ return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
+ }
+}
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/SimpleJob.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java
similarity index 97%
rename from spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/SimpleJob.java
rename to spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java
index 70aa8fc73..9fbf6d9a3 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/SimpleJob.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.batch.execution.job.simple;
+package org.springframework.batch.execution.job;
import java.util.Date;
import java.util.Iterator;
@@ -25,7 +25,6 @@ import org.springframework.batch.core.domain.BatchStatus;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobInterruptedException;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
@@ -42,7 +41,7 @@ import org.springframework.batch.repeat.ExitStatus;
* @author Lucas Ward
* @author Dave Syer
*/
-public class SimpleJob extends JobSupport {
+public class SimpleJob extends AbstractJob {
private JobRepository jobRepository;
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/package.html b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/package.html
deleted file mode 100644
index 055e8d524..000000000
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/package.html
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-Specific implementations of simple job concerns.
-
-
-
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java
index 7ccf563d1..a0c654758 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java
@@ -16,7 +16,6 @@
package org.springframework.batch.execution.launch;
import org.springframework.batch.core.domain.Job;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobParameters;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
@@ -36,7 +35,7 @@ import org.springframework.batch.core.repository.JobExecutionAlreadyRunningExcep
public interface JobLauncher {
/**
- * Start a job execution for the given {@link JobSupport} and {@link JobParameters}.
+ * Start a job execution for the given {@link Job} and {@link JobParameters}.
*
* @return the exit code from the job if it returns synchronously. If the
* implementation is asynchronous, the status might well be unknown.
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java
index 89e4f6d5a..1e5669a80 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java
@@ -21,7 +21,6 @@ import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.InitializingBean;
@@ -31,7 +30,7 @@ import org.springframework.util.Assert;
/**
* Simple implementation of the {@link JobLauncher} interface. The Spring Core
- * {@link TaskExecutor} interface is used to launch a {@link JobSupport}. This
+ * {@link TaskExecutor} interface is used to launch a {@link Job}. This
* means that the type of executor set is very important. If a
* {@link SyncTaskExecutor} is used, then the job will be processed
* within the same thread that called the launcher. Care
@@ -42,7 +41,7 @@ import org.springframework.util.Assert;
* There is only one required dependency of this Launcher, a
* {@link JobRepository}. The JobRepository is used to obtain a valid
* JobExecution. The Repository must be used because the provided
- * {@link JobSupport} could be a restart of an existing {@link JobInstance},
+ * {@link Job} could be a restart of an existing {@link JobInstance},
* and only the Repository can reliably recreate it.
*
* @author Lucas Ward
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java
index f27b68ac5..86b27c026 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java
@@ -24,7 +24,6 @@ import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.core.repository.BatchRestartException;
@@ -88,7 +87,7 @@ public class SimpleJobRepository implements JobRepository {
*
* There are two ways in which the method determines if a job should be
* created or an existing one should be returned. The first is
- * restartability. The {@link JobSupport} restartable property will be
+ * restartability. The {@link Job} restartable property will be
* checked first. If it is false, a new job will be created, regardless of
* whether or not one exists. If it is true, the {@link JobInstanceDao} will
* be checked to determine if the job already exists, if it does, it's steps
@@ -107,7 +106,7 @@ public class SimpleJobRepository implements JobRepository {
*
- What happens then depends on how many existing job instances we
* find:
*
- * - If there are none, or the {@link JobSupport} is marked restartable,
+ *
- If there are none, or the {@link Job} is marked restartable,
* then we create a new {@link JobInstance}
* - If there is more than one and the {@link JobSupport} is not marked
* as restartable, it is an error. This could be caused by a job whose
@@ -131,7 +130,7 @@ public class SimpleJobRepository implements JobRepository {
* or if the platform does not support the higher isolation levels).
*
*
- * @see JobRepository#createJobExecution(JobSupport, JobParameters)
+ * @see JobRepository#createJobExecution(Job, JobParameters)
*
* @throws BatchRestartException if more than one JobInstance if found or if
* JobInstance.getJobExecutionCount() is greater than Job.getStartLimit()
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java
index 536a47cc0..a6c95525e 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java
@@ -20,7 +20,6 @@ import org.springframework.batch.core.domain.ItemSkipPolicy;
import org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.execution.step.support.DefaultItemFailureHandler;
import org.springframework.batch.execution.step.support.NeverSkipItemSkipPolicy;
@@ -30,6 +29,7 @@ import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.stream.StreamManager;
import org.springframework.batch.repeat.exception.handler.ExceptionHandler;
import org.springframework.batch.retry.RetryPolicy;
+import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.Assert;
@@ -40,7 +40,7 @@ import org.springframework.util.Assert;
* @author Dave Syer
* @author Ben Hale
*/
-public abstract class AbstractStep extends StepSupport implements InitializingBean {
+public abstract class AbstractStep implements Step, InitializingBean, BeanNameAware {
protected ExceptionHandler exceptionHandler;
@@ -59,6 +59,12 @@ public abstract class AbstractStep extends StepSupport implements InitializingBe
protected ItemSkipPolicy itemSkipPolicy = new NeverSkipItemSkipPolicy();
protected ItemFailureHandler itemFailureHandler = new DefaultItemFailureHandler();
+
+ protected String name;
+
+ protected int startLimit = Integer.MAX_VALUE;
+
+ protected boolean allowStartIfComplete;
/**
* Default constructor.
@@ -67,13 +73,65 @@ public abstract class AbstractStep extends StepSupport implements InitializingBe
super();
}
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the
+ * name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent
+ * bean has a name, then its children need an explicit name as well, otherwise they will not be unique.
+ *
+ * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
+ */
+ public void setBeanName(String name) {
+ if (this.name == null) {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Set the name property. Always overrides the default value if this object is a Spring bean.
+ *
+ * @see #setBeanName(java.lang.String)
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getStartLimit() {
+ return this.startLimit;
+ }
+
+ /**
+ * Public setter for the startLimit.
+ *
+ * @param startLimit the startLimit to set
+ */
+ public void setStartLimit(int startLimit) {
+ this.startLimit = startLimit;
+ }
+
+ public boolean isAllowStartIfComplete() {
+ return this.allowStartIfComplete;
+ }
+
+ /**
+ * Public setter for the shouldAllowStartIfComplete.
+ *
+ * @param allowStartIfComplete the shouldAllowStartIfComplete to set
+ */
+ public void setAllowStartIfComplete(boolean allowStartIfComplete) {
+ this.allowStartIfComplete = allowStartIfComplete;
+ }
+
/**
* Convenient constructor for setting only the name property.
*
* @param name
*/
public AbstractStep(String name) {
- super(name);
+ this.name = name;
}
/**
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java
index 975eabd43..b96236d13 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java
@@ -237,7 +237,7 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean {
StepSynchronizationManager.register(stepContext);
possiblyRegisterStreams();
- if (isSaveExecutionContext() && isRestart && lastStepExecution != null) {
+ if (isRestart && lastStepExecution != null) {
stepExecution.setExecutionContext(lastStepExecution.getExecutionContext());
}
else {
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java
index 15d1f8bbc..052a15e7a 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java
@@ -23,7 +23,6 @@ import org.springframework.batch.core.domain.BatchStatus;
import org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.tasklet.Tasklet;
import org.springframework.batch.execution.scope.SimpleStepContext;
@@ -36,6 +35,7 @@ import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatListener;
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
import org.springframework.batch.repeat.support.RepeatTemplate;
+import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
@@ -46,13 +46,72 @@ import org.springframework.util.Assert;
*
* @author Ben Hale
*/
-public class TaskletStep extends StepSupport implements InitializingBean {
+public class TaskletStep implements Step, InitializingBean, BeanNameAware {
private static final Log logger = LogFactory.getLog(TaskletStep.class);
private Tasklet tasklet;
private JobRepository jobRepository;
+
+ private String name;
+
+ private int startLimit = Integer.MAX_VALUE;
+
+ private boolean allowStartIfComplete;
+
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the
+ * name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent
+ * bean has a name, then its children need an explicit name as well, otherwise they will not be unique.
+ *
+ * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
+ */
+ public void setBeanName(String name) {
+ if (this.name == null) {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Set the name property. Always overrides the default value if this object is a Spring bean.
+ *
+ * @see #setBeanName(java.lang.String)
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getStartLimit() {
+ return this.startLimit;
+ }
+
+ /**
+ * Public setter for the startLimit.
+ *
+ * @param startLimit the startLimit to set
+ */
+ public void setStartLimit(int startLimit) {
+ this.startLimit = startLimit;
+ }
+
+ public boolean isAllowStartIfComplete() {
+ return this.allowStartIfComplete;
+ }
+
+ /**
+ * Public setter for the shouldAllowStartIfComplete.
+ *
+ * @param allowStartIfComplete the shouldAllowStartIfComplete to set
+ */
+ public void setAllowStartIfComplete(boolean allowStartIfComplete) {
+ this.allowStartIfComplete = allowStartIfComplete;
+ }
+
private RepeatListener[] listeners = new RepeatListener[] {};
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java
index bd6283c15..c56473475 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java
@@ -25,13 +25,13 @@ import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobParameters;
import org.springframework.batch.core.domain.JobParametersBuilder;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.runtime.JobParametersFactory;
import org.springframework.batch.execution.configuration.MapJobRegistry;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.launch.JobLauncher;
+import org.springframework.batch.execution.step.StepSupport;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.support.PropertiesConverter;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessorTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessorTests.java
index 2ad1247e0..1c9342892 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessorTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/JobRegistryBeanPostProcessorTests.java
@@ -19,9 +19,9 @@ import java.util.Collection;
import junit.framework.TestCase;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.repository.DuplicateJobException;
import org.springframework.batch.core.repository.NoSuchJobException;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.beans.FatalBeanException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/MapJobRegistryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/MapJobRegistryTests.java
index 388bfbf1f..791adb3f2 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/MapJobRegistryTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/MapJobRegistryTests.java
@@ -20,10 +20,10 @@ import java.util.Collection;
import junit.framework.TestCase;
import org.springframework.batch.core.domain.Job;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.repository.DuplicateJobException;
import org.springframework.batch.core.repository.NoSuchJobException;
import org.springframework.batch.execution.configuration.MapJobRegistry;
+import org.springframework.batch.execution.job.JobSupport;
/**
* @author Dave Syer
@@ -34,7 +34,7 @@ public class MapJobRegistryTests extends TestCase {
private MapJobRegistry registry = new MapJobRegistry();
/**
- * Test method for {@link org.springframework.batch.execution.configuration.MapJobRegistry#unregister(org.springframework.batch.core.domain.JobSupport)}.
+ * Test method for {@link org.springframework.batch.execution.configuration.MapJobRegistry#unregister(org.springframework.batch.execution.job.JobSupport)}.
* @throws Exception
*/
public void testUnregister() throws Exception {
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/AbstractJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/AbstractJobTests.java
new file mode 100644
index 000000000..ba001e4b2
--- /dev/null
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/AbstractJobTests.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2006-2007 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.execution.job;
+
+import java.util.Collections;
+
+import org.springframework.batch.execution.step.StepSupport;
+
+
+import junit.framework.TestCase;
+
+/**
+ * @author Dave Syer
+ *
+ */
+public class AbstractJobTests extends TestCase {
+
+ JobSupport job = new JobSupport("job");
+
+ /**
+ * Test method for
+ * {@link org.springframework.batch.execution.job.AbstractJob#JobConfiguration()}.
+ */
+ public void testJobConfiguration() {
+ job = new JobSupport();
+ assertNull(job.getName());
+ }
+
+ /**
+ * Test method for
+ * {@link org.springframework.batch.execution.job.AbstractJob#setBeanName(java.lang.String)}.
+ */
+ public void testSetBeanName() {
+ job.setBeanName("foo");
+ assertEquals("job", job.getName());
+ }
+
+ /**
+ * Test method for
+ * {@link org.springframework.batch.execution.job.AbstractJob#setBeanName(java.lang.String)}.
+ */
+ public void testSetBeanNameWithNullName() {
+ job = new JobSupport(null);
+ assertEquals(null, job.getName());
+ job.setBeanName("foo");
+ assertEquals("foo", job.getName());
+ }
+
+ /**
+ * Test method for
+ * {@link org.springframework.batch.execution.job.AbstractJob#setStepNames(java.util.List)}.
+ */
+ public void testSetSteps() {
+ job.setSteps(Collections.singletonList(new StepSupport("step")));
+ assertEquals(1, job.getSteps().size());
+ }
+
+ /**
+ * Test method for
+ * {@link org.springframework.batch.execution.job.AbstractJob#addStepName(org.springframework.batch.core.configuration.StepConfiguration)}.
+ */
+ public void testAddStep() {
+ job.addStep(new StepSupport("step"));
+ assertEquals(1, job.getSteps().size());
+ }
+
+ /**
+ * Test method for
+ * {@link org.springframework.batch.execution.job.AbstractJob#setStartLimit(int)}.
+ */
+ public void testSetStartLimit() {
+ assertEquals(Integer.MAX_VALUE, job.getStartLimit());
+ job.setStartLimit(10);
+ assertEquals(10, job.getStartLimit());
+ }
+
+ /**
+ * Test method for
+ * {@link org.springframework.batch.execution.job.AbstractJob#setRestartable(boolean)}.
+ */
+ public void testSetRestartable() {
+ assertFalse(job.isRestartable());
+ job.setRestartable(true);
+ assertTrue(job.isRestartable());
+ }
+
+ public void testToString() throws Exception {
+ String value = job.toString();
+ assertTrue("Should contain name: "+value, value.indexOf("name=")>=0);
+ }
+
+ public void testRunNotSupported() throws Exception {
+ try {
+ job.execute(null);
+ } catch (UnsupportedOperationException e) {
+ // expected
+ String message = e.getMessage();
+ assertTrue("Message should contain JobSupport: "+message, message.contains("JobSupport"));
+ }
+ }
+
+}
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java
new file mode 100644
index 000000000..3055617a7
--- /dev/null
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2006-2007 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.execution.job;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.batch.core.domain.Job;
+import org.springframework.batch.core.domain.JobExecution;
+import org.springframework.batch.core.domain.Step;
+import org.springframework.batch.io.exception.BatchCriticalException;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.util.ClassUtils;
+
+/**
+ * Batch domain object representing a job. Job is an explicit abstraction
+ * representing the configuration of a job specified by a developer. It should
+ * be noted that restart policy is applied to the job as a whole and not to a
+ * step.
+ *
+ * @author Lucas Ward
+ * @author Dave Syer
+ */
+public class JobSupport implements BeanNameAware, Job {
+
+ private List steps = new ArrayList();
+
+ private String name;
+
+ private boolean restartable = false;
+
+ private int startLimit = Integer.MAX_VALUE;
+
+ /**
+ * Default constructor.
+ */
+ public JobSupport() {
+ super();
+ }
+
+ /**
+ * Convenience constructor to immediately add name (which is mandatory but
+ * not final).
+ *
+ * @param name
+ */
+ public JobSupport(String name) {
+ super();
+ this.name = name;
+ }
+
+ /**
+ * Set the name property if it is not already set. Because of the order of
+ * the callbacks in a Spring container the name property will be set first
+ * if it is present. Care is needed with bean definition inheritance - if a
+ * parent bean has a name, then its children need an explicit name as well,
+ * otherwise they will not be unique.
+ *
+ * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
+ */
+ public void setBeanName(String name) {
+ if (this.name == null) {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Set the name property. Always overrides the default value if this object
+ * is a Spring bean.
+ *
+ * @see #setBeanName(java.lang.String)
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#getSteps()
+ */
+ public List getSteps() {
+ return steps;
+ }
+
+ public void setSteps(List steps) {
+ this.steps.clear();
+ this.steps.addAll(steps);
+ }
+
+ public void addStep(Step step) {
+ this.steps.add(step);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#getStartLimit()
+ */
+ public int getStartLimit() {
+ return startLimit;
+ }
+
+ public void setStartLimit(int startLimit) {
+ this.startLimit = startLimit;
+ }
+
+ public void setRestartable(boolean restartable) {
+ this.restartable = restartable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.IJob#isRestartable()
+ */
+ public boolean isRestartable() {
+ return restartable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution)
+ */
+ public void execute(JobExecution execution) throws BatchCriticalException {
+ throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass.");
+ }
+
+ public String toString() {
+ return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
+ }
+}
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/simple/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java
similarity index 98%
rename from spring-batch-execution/src/test/java/org/springframework/batch/execution/job/simple/SimpleJobTests.java
rename to spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java
index fec02f292..75538a178 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/simple/SimpleJobTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.batch.execution.job.simple;
+package org.springframework.batch.execution.job;
import java.util.ArrayList;
import java.util.List;
@@ -30,6 +30,7 @@ import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
+import org.springframework.batch.execution.job.SimpleJob;
import org.springframework.batch.execution.repository.SimpleJobRepository;
import org.springframework.batch.execution.repository.dao.JobExecutionDao;
import org.springframework.batch.execution.repository.dao.JobInstanceDao;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java
index e0ae3fc81..c54ae8679 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java
@@ -25,8 +25,8 @@ import org.easymock.MockControl;
import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.repository.JobRepository;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.core.task.TaskExecutor;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java
index 13dc0f98b..0f77d0f4f 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java
@@ -28,7 +28,7 @@ import org.springframework.batch.core.domain.ItemFailureHandler;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.execution.job.simple.SimpleJob;
+import org.springframework.batch.execution.job.SimpleJob;
import org.springframework.batch.execution.repository.SimpleJobRepository;
import org.springframework.batch.execution.repository.dao.MapJobDao;
import org.springframework.batch.execution.repository.dao.MapStepDao;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java
index b82f458d7..0bbdf803e 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java
@@ -6,7 +6,7 @@ import java.util.Map;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
import org.springframework.util.ClassUtils;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java
index 5d255d80b..850da98cf 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java
@@ -26,14 +26,14 @@ import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
import org.springframework.batch.core.domain.JobParametersBuilder;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
import org.springframework.batch.core.repository.BatchRestartException;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.repository.dao.JobExecutionDao;
import org.springframework.batch.execution.repository.dao.JobInstanceDao;
import org.springframework.batch.execution.repository.dao.StepExecutionDao;
+import org.springframework.batch.execution.step.StepSupport;
import org.springframework.batch.item.ExecutionContext;
/**
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java
index f0bc47a40..dbbf9b849 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java
@@ -26,8 +26,8 @@ import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
import org.springframework.batch.core.domain.JobParametersBuilder;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
import org.springframework.util.ClassUtils;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java
index 6539e4537..aeea1538b 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java
@@ -22,11 +22,11 @@ import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
+import org.springframework.batch.execution.job.JobSupport;
+import org.springframework.batch.execution.step.StepSupport;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.dao.OptimisticLockingFailureException;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java
index 3130d7e3a..4ba572fe1 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java
@@ -22,7 +22,7 @@ import junit.framework.TestCase;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java
index 9201cde20..667b0c463 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java
@@ -8,10 +8,10 @@ import org.easymock.MockControl;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
+import org.springframework.batch.execution.job.JobSupport;
+import org.springframework.batch.execution.step.StepSupport;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java
index ddf406485..4c6209ecd 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java
@@ -24,7 +24,7 @@ import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
+import org.springframework.batch.execution.job.JobSupport;
public class MapJobDaoTests extends TestCase {
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java
index 9781355f7..8d3179e5b 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java
@@ -21,10 +21,10 @@ import junit.framework.TestCase;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
+import org.springframework.batch.execution.job.JobSupport;
+import org.springframework.batch.execution.step.StepSupport;
public class MapStepDaoTests extends TestCase {
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java
index 8c2d540f5..8f5ccd28d 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java
@@ -25,10 +25,10 @@ import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
import org.springframework.batch.core.domain.JobParametersBuilder;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
-import org.springframework.batch.core.domain.StepSupport;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.scope.SimpleStepContext;
+import org.springframework.batch.execution.step.StepSupport;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java
index b633b317b..d58ccef19 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java
@@ -21,7 +21,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
+import org.springframework.batch.execution.step.StepSupport;
/**
* @author Dave Syer
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java
index 1f94c94ca..20054459b 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java
@@ -22,8 +22,8 @@ import junit.framework.TestCase;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
-import org.springframework.batch.core.domain.JobSupport;
-import org.springframework.batch.core.domain.StepSupport;
+import org.springframework.batch.execution.job.JobSupport;
+import org.springframework.batch.execution.step.StepSupport;
import org.springframework.batch.repeat.synch.RepeatSynchronizationManager;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectFactory;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java
index d2a1e49f3..145ef794d 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java
@@ -27,11 +27,10 @@ import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepContribution;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.repository.SimpleJobRepository;
import org.springframework.batch.execution.repository.dao.MapJobDao;
import org.springframework.batch.execution.repository.dao.MapStepDao;
@@ -277,7 +276,6 @@ public class ItemOrientedStepTests extends TestCase {
Step step = new StepSupport("stepName");
MockRestartableItemReader tasklet = new MockRestartableItemReader();
itemOrientedStep.setItemReader(tasklet);
- itemOrientedStep.setSaveExecutionContext(true);
JobExecution jobExecutionContext = new JobExecution(jobInstance);
StepExecution stepExecution = new StepExecution(step, jobExecutionContext);
@@ -319,7 +317,6 @@ public class ItemOrientedStepTests extends TestCase {
Step step = new StepSupport("stepName");
MockRestartableItemReader tasklet = new MockRestartableItemReader();
itemOrientedStep.setItemReader(tasklet);
- itemOrientedStep.setSaveExecutionContext(false);
JobExecution jobExecutionContext = new JobExecution(jobInstance);
StepExecution stepExecution = new StepExecution(step, jobExecutionContext);
@@ -345,7 +342,6 @@ public class ItemOrientedStepTests extends TestCase {
return "foo";
}
});
- itemOrientedStep.setSaveExecutionContext(true);
JobExecution jobExecution = new JobExecution(jobInstance);
StepExecution stepExecution = new StepExecution(step, jobExecution);
@@ -371,7 +367,6 @@ public class ItemOrientedStepTests extends TestCase {
return "foo";
}
});
- itemOrientedStep.setSaveExecutionContext(true);
JobExecution jobExecution = new JobExecution(jobInstance);
StepExecution stepExecution = new StepExecution(step, jobExecution);
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java
new file mode 100644
index 000000000..74c6c9755
--- /dev/null
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2006-2007 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.execution.step;
+
+import org.springframework.batch.core.domain.JobInterruptedException;
+import org.springframework.batch.core.domain.Step;
+import org.springframework.batch.core.domain.StepExecution;
+import org.springframework.batch.io.exception.BatchCriticalException;
+import org.springframework.beans.factory.BeanNameAware;
+
+/**
+ * Basic no-op support implementation for use as base class for {@link Step}. Implements {@link BeanNameAware} so that
+ * if no name is provided explicitly it will be inferred from the bean definition in Spring configuration.
+ *
+ * @author Dave Syer
+ *
+ */
+public class StepSupport implements Step, BeanNameAware {
+
+ private String name;
+
+ private int startLimit = Integer.MAX_VALUE;
+
+ private boolean allowStartIfComplete;
+
+ /**
+ * Default constructor for {@link StepSupport}.
+ */
+ public StepSupport() {
+ super();
+ }
+
+ /**
+ * @param string
+ */
+ public StepSupport(String string) {
+ super();
+ this.name = string;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the
+ * name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent
+ * bean has a name, then its children need an explicit name as well, otherwise they will not be unique.
+ *
+ * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
+ */
+ public void setBeanName(String name) {
+ if (this.name == null) {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Set the name property. Always overrides the default value if this object is a Spring bean.
+ *
+ * @see #setBeanName(java.lang.String)
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getStartLimit() {
+ return this.startLimit;
+ }
+
+ /**
+ * Public setter for the startLimit.
+ *
+ * @param startLimit the startLimit to set
+ */
+ public void setStartLimit(int startLimit) {
+ this.startLimit = startLimit;
+ }
+
+ public boolean isAllowStartIfComplete() {
+ return this.allowStartIfComplete;
+ }
+
+ /**
+ * Public setter for the shouldAllowStartIfComplete.
+ *
+ * @param allowStartIfComplete the shouldAllowStartIfComplete to set
+ */
+ public void setAllowStartIfComplete(boolean allowStartIfComplete) {
+ this.allowStartIfComplete = allowStartIfComplete;
+ }
+
+ /**
+ * Not supported but provided so that tests can easily create a step.
+ *
+ * @throws UnsupportedOperationException always
+ *
+ * @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution)
+ */
+ public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException {
+ throw new UnsupportedOperationException(
+ "Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
+ }
+}
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java
index 8d36ac47e..f15fd66d6 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java
@@ -9,10 +9,9 @@ import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.StepExecution;
-import org.springframework.batch.core.domain.StepSupport;
import org.springframework.batch.core.tasklet.Tasklet;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.scope.StepSynchronizationManager;
import org.springframework.batch.execution.step.support.JobRepositorySupport;
import org.springframework.batch.io.exception.BatchCriticalException;
diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java
index cbe9613f6..f4ad4a5db 100644
--- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java
+++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java
@@ -23,9 +23,9 @@ import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.domain.JobParameters;
-import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
+import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.repository.SimpleJobRepository;
import org.springframework.batch.execution.repository.dao.JobExecutionDao;
import org.springframework.batch.execution.repository.dao.JobInstanceDao;
diff --git a/spring-batch-execution/src/test/resources/job-configuration.xml b/spring-batch-execution/src/test/resources/job-configuration.xml
index 9b8176c8a..a47af9d00 100644
--- a/spring-batch-execution/src/test/resources/job-configuration.xml
+++ b/spring-batch-execution/src/test/resources/job-configuration.xml
@@ -15,7 +15,7 @@
+ class="org.springframework.batch.execution.job.JobSupport">
diff --git a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml
index b27b10966..6158a414e 100644
--- a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml
+++ b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml
@@ -10,7 +10,7 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
+ class="org.springframework.batch.execution.job.JobSupport">
diff --git a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/configuration/test-context.xml b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/configuration/test-context.xml
index 4cb078c9a..dbcb19c90 100644
--- a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/configuration/test-context.xml
+++ b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/configuration/test-context.xml
@@ -18,7 +18,7 @@
class="org.springframework.batch.execution.configuration.MapJobRegistry" />
+ class="org.springframework.batch.execution.job.JobSupport">
@@ -44,17 +44,17 @@
+ class="org.springframework.batch.execution.job.JobSupport">
+ class="org.springframework.batch.execution.job.JobSupport">
@@ -66,7 +66,7 @@
p:name="bucket" />
+ class="org.springframework.batch.execution.job.JobSupport" />
diff --git a/spring-batch-execution/src/test/resources/simple-container-definition.xml b/spring-batch-execution/src/test/resources/simple-container-definition.xml
index 9a2b3e180..b0192e051 100644
--- a/spring-batch-execution/src/test/resources/simple-container-definition.xml
+++ b/spring-batch-execution/src/test/resources/simple-container-definition.xml
@@ -18,7 +18,7 @@
class="org.springframework.batch.execution.configuration.MapJobRegistry" />
@@ -28,7 +28,6 @@
class="org.springframework.batch.execution.step.ItemOrientedStep"
abstract="true">
-