title: Spring Batch delay step initializing
body: <p>I have a Spring Batch job with two steps. The first one downloads a file and the second on processes the file. The problem is the second step does not know what the name of the file is until the first step has been run.</p>
  
  <p>The job automatically already instantaties the steps so it can be run when needed. I can't think of any way to make sure the step initializes after the first step has been run. </p>
  
  <p>This is the code:</p>
  
  <pre><code>    @Bean
  public Job insertIntoDbFromCsvb(){
      return jobs.get("Insert Entity Records Job")
              .incrementer(new RunIdIncrementer())
               .listener(new InsertRecordListener())
              .start(downloadFileStep())
              .next(insertIntoDBStep())
              .build();
  }
  
  @Bean
  ItemProcessor&lt;Entity, Entity&gt; csvEntityProcessor() {
      return new EntityItemProcessor();
  }
  
  @Bean
  public Step insertIntoDBStep(){
      return steps.get("Insert Entity Records Step")
              .&lt;Entity, Entity&gt;chunk(500)
              .reader(csvFileReader())
              .processor(csvEntityProcessor())
              .writer(itemWriter())
              .build();
  }
  
  @Bean
  public Step downloadFileStep(){
      return steps.get("Download File Step")
              .tasklet(new DownloadFileTasklet("https://leidata-preview.gleif.org/storage/golden-copy-files/2018/06/14/49694/20180614-0000-gleif-goldencopy-lei2-golden-copy.csv.zip",
                      fileDao,
                      FileAction.INIT_ENTITY,
                      this))
              .allowStartIfComplete(true)
              .build();
  }
  
  @Bean
  public FlatFileItemReader&lt;Entity&gt; csvFileReader(){
      System.out.println("file name: " + fileName);
      FlatFileItemReader&lt;Entity&gt; reader = new FlatFileItemReader&lt;&gt;();
      reader.setResource(new ClassPathResource("data/"+this.fileName));
      reader.setStrict(false);
      reader.setLinesToSkip(1);
      reader.setLineMapper(lineMapper());
  
      return reader;
  }
  </code></pre>
  
  <p>You can see that <code>reader.setResource(new ClassPathResource("data/"+this.fileName));</code> takes the local variable <code>fileName</code> that I set in the Tasklet of the first step.</p>