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 c902e5a95..0b61ad259 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,6 +17,7 @@ package org.springframework.batch.core.job; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.springframework.batch.core.BatchStatus; @@ -39,7 +40,7 @@ import org.springframework.batch.core.repository.JobRestartException; public class SimpleJob extends AbstractJob { private List steps = new ArrayList(); - + /** * Default constructor for job with null name */ @@ -65,6 +66,15 @@ public class SimpleJob extends AbstractJob { this.steps.addAll(steps); } + /** + * Convenience method for clients to inspect the steps for this job. + * + * @return an unmodifiable copy of the steps for this job + */ + public List getSteps() { + return Collections.unmodifiableList(steps); + } + /** * Convenience method for adding a single step to the job. * @@ -73,21 +83,22 @@ public class SimpleJob extends AbstractJob { public void addStep(Step step) { this.steps.add(step); } - - /* + + /* * (non-Javadoc) - * @see org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String) + * + * @see + * org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String) */ - public Step getStep(String stepName){ + public Step getStep(String stepName) { for (Step step : this.steps) { - if(step.getName().equals(stepName)) - { + if (step.getName().equals(stepName)) { return step; } } return null; } - + /** * Handler of steps sequentially as provided, checking each one for success * before moving to the next. Returns the last {@link StepExecution} @@ -114,8 +125,8 @@ public class SimpleJob extends AbstractJob { // // Update the job status to be the same as the last step // - if(stepExecution != null) { - logger.debug("Upgrading JobExecution status: "+stepExecution); + if (stepExecution != null) { + logger.debug("Upgrading JobExecution status: " + stepExecution); execution.upgradeStatus(stepExecution.getStatus()); execution.setExitStatus(stepExecution.getExitStatus()); }