How Does Spring Batch Step Scope Work
<p>I have a requirement where I need to process files  based on the rest call in which I get the name of the file, I am adding it to the job parameter and using it while creating the beans.</p>

<p>I am creating step scope Beans for (reader,writer) and using the job parameter.I am starting the job in a new thread as I am using asynchronus task exceutor to launch the job and my question is how will the beans be created by spring when we define <code>@StepScope</code></p>

<pre><code>jobParametersBuilder.addString("fileName", request.getFileName());
jobExecution = jobLauncher.run(job, jobParametersBuilder.toJobParameters());
@Bean
public JobLauncher jobLauncher() {
    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository());
    jobLauncher.setTaskExecutor(asyncTaskExecutor());
    return jobLauncher;
}

@Bean
@StepScope
public ItemWriter&lt;Object&gt; writer(@Value ("#{jobParameters['fileName']}"String    fileName) {
    JdbcBatchItemWriter&lt;Object&gt; writer = new JdbcBatchItemWriter&lt;&gt;();
    writer.setItemSqlParameterSourceProvider(
        new BeanPropertyItemSqlParameterSourceProvider&lt;Object&gt;());
    writer.setSql(queryCollection.getquery());
    writer.setDataSource(dataSource(fileName));
    return writer;
}
</code></pre>