diff --git a/core/src/main/java/org/springframework/batch/core/configuration/StepConfiguration.java b/core/src/main/java/org/springframework/batch/core/configuration/StepConfiguration.java index d00233daa..d4035205a 100644 --- a/core/src/main/java/org/springframework/batch/core/configuration/StepConfiguration.java +++ b/core/src/main/java/org/springframework/batch/core/configuration/StepConfiguration.java @@ -40,10 +40,16 @@ public interface StepConfiguration { Tasklet getTasklet(); /** - * @return true if a job that is already marked as complete can be started + * @return true if a step that is already marked as complete can be started * again. */ boolean isAllowStartIfComplete(); + + /** + * Flag to indicate if restart data needs to be saved for this step. + * @return true if restart data should be saved + */ + boolean isSaveRestartData(); /** * @return the number of times a job can be started with the same diff --git a/core/src/main/java/org/springframework/batch/core/configuration/StepConfigurationSupport.java b/core/src/main/java/org/springframework/batch/core/configuration/StepConfigurationSupport.java index e0a6d237c..35e9c9cb6 100644 --- a/core/src/main/java/org/springframework/batch/core/configuration/StepConfigurationSupport.java +++ b/core/src/main/java/org/springframework/batch/core/configuration/StepConfigurationSupport.java @@ -30,6 +30,7 @@ public class StepConfigurationSupport implements StepConfiguration { private int startLimit = Integer.MAX_VALUE; private Tasklet tasklet; private boolean allowStartIfComplete; + private boolean saveRestartData = false; /** * Default constructor for {@link StepConfigurationSupport}. @@ -114,4 +115,12 @@ public class StepConfigurationSupport implements StepConfiguration { this.allowStartIfComplete = allowStartIfComplete; } + public void setSaveRestartData(boolean saveRestartData) { + this.saveRestartData = saveRestartData; + } + + public boolean isSaveRestartData() { + return saveRestartData; + } + } diff --git a/core/src/main/java/org/springframework/batch/core/domain/JobExecution.java b/core/src/main/java/org/springframework/batch/core/domain/JobExecution.java index bf364831f..df182eaf2 100644 --- a/core/src/main/java/org/springframework/batch/core/domain/JobExecution.java +++ b/core/src/main/java/org/springframework/batch/core/domain/JobExecution.java @@ -20,7 +20,6 @@ import java.sql.Timestamp; import java.util.Collection; import java.util.HashSet; -import org.springframework.batch.core.runtime.JobIdentifier; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.repeat.RepeatContext; diff --git a/core/src/main/java/org/springframework/batch/core/domain/JobIdentifier.java b/core/src/main/java/org/springframework/batch/core/domain/JobIdentifier.java new file mode 100644 index 000000000..2f61b6e55 --- /dev/null +++ b/core/src/main/java/org/springframework/batch/core/domain/JobIdentifier.java @@ -0,0 +1,39 @@ +/* + * 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.core.domain; + + +/** + * Identifier strategy for {@link JobInstance}. Different batch projects can + * have different approaches and requirements regarding the identity of a job. + * The minimum requirement is to provide a unique name to identify a job. Other + * applications or projects might add other properties like a schedule date, or + * an additional label (code). + * + * @author Dave Syer + * + */ +public interface JobIdentifier { + + /** + * A name property for jobs provided by the {@link JobIdentifier} strategy. + * + * @return the name of the job + */ + public String getName(); + +} diff --git a/core/src/main/java/org/springframework/batch/core/domain/JobInstance.java b/core/src/main/java/org/springframework/batch/core/domain/JobInstance.java index 7f9227779..55f6dceb7 100644 --- a/core/src/main/java/org/springframework/batch/core/domain/JobInstance.java +++ b/core/src/main/java/org/springframework/batch/core/domain/JobInstance.java @@ -19,7 +19,6 @@ package org.springframework.batch.core.domain; import java.util.ArrayList; import java.util.List; -import org.springframework.batch.core.runtime.JobIdentifier; /** * Batch domain object representing a job instance. A job instance is defined as diff --git a/core/src/main/java/org/springframework/batch/core/repository/JobRepository.java b/core/src/main/java/org/springframework/batch/core/repository/JobRepository.java index 34a59f0d1..1cb3be81d 100644 --- a/core/src/main/java/org/springframework/batch/core/repository/JobRepository.java +++ b/core/src/main/java/org/springframework/batch/core/repository/JobRepository.java @@ -18,10 +18,10 @@ package org.springframework.batch.core.repository; import org.springframework.batch.core.configuration.JobConfiguration; import org.springframework.batch.core.domain.JobExecution; +import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.core.runtime.JobIdentifier; /** *
diff --git a/core/src/main/java/org/springframework/batch/core/runtime/JobExecutionRegistry.java b/core/src/main/java/org/springframework/batch/core/runtime/JobExecutionRegistry.java index e45caaf0d..928bd2ada 100644 --- a/core/src/main/java/org/springframework/batch/core/runtime/JobExecutionRegistry.java +++ b/core/src/main/java/org/springframework/batch/core/runtime/JobExecutionRegistry.java @@ -18,6 +18,7 @@ package org.springframework.batch.core.runtime; import java.util.Collection; import org.springframework.batch.core.domain.JobExecution; +import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.domain.JobInstance; /** diff --git a/core/src/main/java/org/springframework/batch/core/runtime/JobIdentifierFactory.java b/core/src/main/java/org/springframework/batch/core/runtime/JobIdentifierFactory.java index b2c490d32..10649d100 100644 --- a/core/src/main/java/org/springframework/batch/core/runtime/JobIdentifierFactory.java +++ b/core/src/main/java/org/springframework/batch/core/runtime/JobIdentifierFactory.java @@ -16,6 +16,8 @@ package org.springframework.batch.core.runtime; +import org.springframework.batch.core.domain.JobIdentifier; + /** * A factory for {@link JobIdentifier} instances. A job configuration can be * executed with many possible runtime parameters, which identify the instance diff --git a/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java b/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java index 2167472ee..6aa71313a 100644 --- a/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java +++ b/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java @@ -17,6 +17,7 @@ package org.springframework.batch.core.runtime; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; +import org.springframework.batch.core.domain.JobIdentifier; /** diff --git a/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactory.java b/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactory.java index 227544034..a880fca45 100644 --- a/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactory.java +++ b/core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactory.java @@ -1,5 +1,7 @@ package org.springframework.batch.core.runtime; +import org.springframework.batch.core.domain.JobIdentifier; + /** * Factory for {@link SimpleJobIdentifier} instances. diff --git a/core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java b/core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java index ae43e847b..defa76cc1 100644 --- a/core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java +++ b/core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java @@ -17,7 +17,6 @@ package org.springframework.batch.core.domain; import java.util.Collections; -import org.springframework.batch.core.runtime.JobIdentifier; import junit.framework.TestCase; diff --git a/core/src/test/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactoryTests.java b/core/src/test/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactoryTests.java index 5abc384ce..dcb69da48 100644 --- a/core/src/test/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactoryTests.java +++ b/core/src/test/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactoryTests.java @@ -1,5 +1,7 @@ package org.springframework.batch.core.runtime; +import org.springframework.batch.core.domain.JobIdentifier; + import junit.framework.TestCase; public class SimpleJobIdentifierFactoryTests extends TestCase {