diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java index 4b77e786f..1277e1908 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java @@ -21,7 +21,7 @@ import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Date; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import org.springframework.batch.item.ExecutionContext; @@ -37,7 +37,7 @@ public class JobExecution extends Entity { private JobInstance jobInstance; - private volatile Collection stepExecutions = new HashSet(); + private volatile Collection stepExecutions = new LinkedHashSet(); private volatile BatchStatus status = BatchStatus.STARTING; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java index 02ab10709..2126cba5b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java @@ -16,12 +16,12 @@ package org.springframework.batch.core.launch.support; import java.util.ArrayList; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -150,7 +150,7 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { * @see org.springframework.batch.core.launch.JobOperator#getJobNames() */ public Set getJobNames() { - return new HashSet(jobRegistry.getJobNames()); + return new TreeSet(jobRegistry.getJobNames()); } /* diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopIncrementer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopIncrementer.java new file mode 100644 index 000000000..35982b395 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopIncrementer.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.sample.common; + +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.JobParametersIncrementer; + +/** + * @author Dave Syer + * + */ +public class InfiniteLoopIncrementer implements JobParametersIncrementer { + + /** + * Increment the run.id parameter. + */ + public JobParameters getNext(JobParameters parameters) { + if (parameters==null || parameters.isEmpty()) { + return new JobParametersBuilder().addLong("run.id", 1L).toJobParameters(); + } + long id = parameters.getLong("run.id",1L) + 1; + return new JobParametersBuilder().addLong("run.id", id).toJobParameters(); + } + +} diff --git a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml index 034aad0b5..da8485ee4 100644 --- a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml @@ -23,6 +23,9 @@ + + +