Add sample JobParametersIncrementer for JMX demo

This commit is contained in:
dsyer
2008-10-07 10:32:51 +00:00
parent 7ad93d227e
commit c5444c4fe9
4 changed files with 46 additions and 4 deletions

View File

@@ -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<StepExecution> stepExecutions = new HashSet<StepExecution>();
private volatile Collection<StepExecution> stepExecutions = new LinkedHashSet<StepExecution>();
private volatile BatchStatus status = BatchStatus.STARTING;

View File

@@ -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<String> getJobNames() {
return new HashSet<String>(jobRegistry.getJobNames());
return new TreeSet<String>(jobRegistry.getJobNames());
}
/*

View File

@@ -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();
}
}

View File

@@ -23,6 +23,9 @@
</property>
</bean>
</property>
<property name="jobParametersIncrementer">
<bean class="org.springframework.batch.sample.common.InfiniteLoopIncrementer"/>
</property>
</bean>
<aop:config>