diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClassPathXmlApplicationContextJobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClassPathXmlApplicationContextJobFactory.java index 4741ba752..d1754a622 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClassPathXmlApplicationContextJobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClassPathXmlApplicationContextJobFactory.java @@ -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 getSteps() { return delegate.getSteps(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java index 3f01ffd4d..f0e9676e9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java @@ -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 jobNames = new HashSet(); /** * 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(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java index d5cc6f5ab..d41356b7a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java @@ -38,7 +38,7 @@ import org.springframework.util.Assert; */ public class MapJobRegistry implements ListableJobRegistry { - private Map map = new HashMap(); + private Map map = new HashMap(); /* * (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 getJobNames() { synchronized (map) { - return Collections.unmodifiableCollection(new HashSet(map.keySet())); + return Collections.unmodifiableCollection(new HashSet(map.keySet())); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java index be167adf7..490ad194b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java @@ -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> it = props.entrySet().iterator(); it.hasNext();) { + Entry 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 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 entry : parameters.entrySet()) { + + String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof Date) { result.setProperty(key + DATE_TYPE, dateFormat.format(value)); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java index e565a306e..e788c892b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java @@ -40,7 +40,7 @@ import org.springframework.util.ClassUtils; */ public abstract class AbstractJob implements Job, BeanNameAware, InitializingBean { - private List steps = new ArrayList(); + private List steps = new ArrayList(); 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 getSteps() { return steps; } - public void setSteps(List steps) { + public void setSteps(List steps) { this.steps.clear(); this.steps.addAll(steps); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java index 41b8193a9..d1e780e78 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java @@ -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 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++; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/AbstractJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/AbstractJobTests.java index e72971d5f..99174322d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/AbstractJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/AbstractJobTests.java @@ -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()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index 50032ddbd..6e6c48824 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -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);