List of usage examples for org.springframework.batch.core.step StepLocator getStepNames
Collection<String> getStepNames();
From source file:org.springframework.batch.core.configuration.support.DefaultJobLoader.java
/** * Returns all the {@link Step} instances defined by the specified {@link StepLocator}. * <br>/*from w ww .ja v a2s. co m*/ * The specified <tt>jobApplicationContext</tt> is used to collect additional steps that * are not exposed by the step locator * * @param stepLocator the given step locator * @param jobApplicationContext the application context of the job * @return all the {@link Step} defined by the given step locator and context * @see StepLocator */ private Collection<Step> getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) { final Collection<String> stepNames = stepLocator.getStepNames(); final Collection<Step> result = new ArrayList<Step>(); for (String stepName : stepNames) { result.add(stepLocator.getStep(stepName)); } // Because some steps are referenced by name, we need to look in the context to see if there // are more Step instances defined. Right now they are registered as being available in the // context of the job but we have no idea if they are linked to that Job or not. final Map<String, Step> allSteps = jobApplicationContext.getBeansOfType(Step.class); for (Map.Entry<String, Step> entry : allSteps.entrySet()) { if (!stepNames.contains(entry.getKey())) { result.add(entry.getValue()); } } return result; }