IN PROGRESS - BATCH-709: Change all collections to use generics

This commit is contained in:
robokaso
2008-07-16 08:44:08 +00:00
parent c7ad3b202c
commit 80dbca8d55
8 changed files with 25 additions and 27 deletions

View File

@@ -20,6 +20,7 @@ import java.util.List;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.JobFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
@@ -141,7 +142,7 @@ public class ClassPathXmlApplicationContextJobFactory implements JobFactory, App
* @deprecated planned for removal in 2.0
* @see org.springframework.batch.core.Job#getSteps()
*/
public List getSteps() {
public List<Step> getSteps() {
return delegate.getSteps();
}

View File

@@ -17,7 +17,6 @@ package org.springframework.batch.core.configuration.support;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.configuration.JobLocator;
@@ -45,7 +44,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, Initiali
// It doesn't make sense for this to have a default value...
private JobRegistry jobConfigurationRegistry = null;
private Collection jobNames = new HashSet();
private Collection<String> jobNames = new HashSet<String>();
/**
* Injection setter for {@link JobRegistry}.
@@ -71,8 +70,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, Initiali
* @see org.springframework.beans.factory.DisposableBean#destroy()
*/
public void destroy() throws Exception {
for (Iterator iter = jobNames.iterator(); iter.hasNext();) {
String name = (String) iter.next();
for (String name : jobNames) {
jobConfigurationRegistry.unregister(name);
}
jobNames.clear();

View File

@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
*/
public class MapJobRegistry implements ListableJobRegistry {
private Map map = new HashMap();
private Map<String, JobFactory> map = new HashMap<String, JobFactory>();
/*
* (non-Javadoc)
@@ -86,9 +86,9 @@ public class MapJobRegistry implements ListableJobRegistry {
* (non-Javadoc)
* @see org.springframework.batch.container.common.configuration.ListableJobConfigurationRegistry#getJobConfigurations()
*/
public Collection getJobNames() {
public Collection<String> getJobNames() {
synchronized (map) {
return Collections.unmodifiableCollection(new HashSet(map.keySet()));
return Collections.unmodifiableCollection(new HashSet<String>(map.keySet()));
}
}

View File

@@ -78,8 +78,8 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
JobParametersBuilder propertiesBuilder = new JobParametersBuilder();
for (Iterator it = props.entrySet().iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
for (Iterator<Entry<Object, Object>> it = props.entrySet().iterator(); it.hasNext();) {
Entry<Object, Object> entry = it.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
if (key.endsWith(DATE_TYPE)) {
@@ -152,11 +152,11 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
return new Properties();
}
Map parameters = params.getParameters();
Map<String, Object> parameters = params.getParameters();
Properties result = new Properties();
for (Iterator iterator = parameters.entrySet().iterator(); iterator.hasNext();) {
Entry entry = (Entry) iterator.next();
String key = (String) entry.getKey();
for (Entry<String, Object> entry : parameters.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof Date) {
result.setProperty(key + DATE_TYPE, dateFormat.format(value));

View File

@@ -40,7 +40,7 @@ import org.springframework.util.ClassUtils;
*/
public abstract class AbstractJob implements Job, BeanNameAware, InitializingBean {
private List steps = new ArrayList();
private List<Step> steps = new ArrayList<Step>();
private String name;
@@ -103,11 +103,11 @@ public abstract class AbstractJob implements Job, BeanNameAware, InitializingBea
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.IJob#getSteps()
*/
public List getSteps() {
public List<Step> getSteps() {
return steps;
}
public void setSteps(List steps) {
public void setSteps(List<Step> steps) {
this.steps.clear();
this.steps.addAll(steps);
}

View File

@@ -17,7 +17,6 @@
package org.springframework.batch.core.job;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.springframework.batch.core.BatchStatus;
@@ -56,7 +55,7 @@ public class SimpleJob extends AbstractJob {
StepExecution currentStepExecution = null;
int startedCount = 0;
List steps = getSteps();
List<Step> steps = getSteps();
try {
@@ -71,14 +70,12 @@ public class SimpleJob extends AbstractJob {
getCompositeListener().beforeJob(execution);
for (Iterator i = steps.iterator(); i.hasNext();) {
for (Step step : steps) {
if (execution.getStatus() == BatchStatus.STOPPING) {
throw new JobInterruptedException("JobExecution interrupted.");
}
Step step = (Step) i.next();
if (shouldStart(jobInstance, step)) {
startedCount++;

View File

@@ -21,6 +21,7 @@ import junit.framework.TestCase;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.step.StepSupport;
/**
@@ -73,7 +74,7 @@ public class AbstractJobTests extends TestCase {
* Test method for {@link org.springframework.batch.core.job.AbstractJob#setSteps(java.util.List)}.
*/
public void testSetSteps() {
job.setSteps(Collections.singletonList(new StepSupport("step")));
job.setSteps(Collections.singletonList((Step) new StepSupport("step")));
assertEquals(1, job.getSteps().size());
}

View File

@@ -23,6 +23,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.ChunkListener;
@@ -181,7 +182,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
step.setChunkOperations(chunkOperations);
job.setSteps(Collections.singletonList(step));
job.setSteps(Collections.singletonList((Step) step));
JobExecution jobExecution = repository.createJobExecution(job, new JobParameters());
job.execute(jobExecution);
@@ -202,7 +203,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
}
});
AbstractStep step = (AbstractStep) factory.getObject();
job.setSteps(Collections.singletonList(step));
job.setSteps(Collections.singletonList((Step) step));
JobExecution jobExecution = repository.createJobExecution(job, new JobParameters());
try {
@@ -230,7 +231,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
}
});
AbstractStep step = (AbstractStep) factory.getObject();
job.setSteps(Collections.singletonList(step));
job.setSteps(Collections.singletonList((Step) step));
JobExecution jobExecution = repository.createJobExecution(job, new JobParameters());
@@ -263,7 +264,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
AbstractStep step = (AbstractStep) factory.getObject();
job.setSteps(Collections.singletonList(step));
job.setSteps(Collections.singletonList((Step) step));
JobExecution jobExecution = repository.createJobExecution(job, new JobParameters());
job.execute(jobExecution);