Uploaded image for project: 'Spring Batch'
  1. Spring Batch
  2. BATCH-2669

Incorrect code examples in "Configuring and Running a Job" documentation

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.0.0
    • Fix Version/s: 4.0.1
    • Component/s: Documentation
    • Labels:

      Description

      Some examples in the "Configuring and Running a Job" section of the documentation are incorrect or do not compile:

      Section 1.6.1

      The following snippet does not compile:

      ...
      // This would reside in your BatchConfigurer implementation
      @Override
      public JobExplorer getJobExplorer() {
              JobExplorerFactoryBean factoryBean = new JobExplorerFactoryBean();
              factoryBean.setDataSource(this.dataSource);
              return factoryBean;
      }}
      ...
      

      I think it should be:

      ...
      // This would reside in your BatchConfigurer implementation
      @Override
      public JobExplorer getJobExplorer() throws Exception {
      	JobExplorerFactoryBean factoryBean = new JobExplorerFactoryBean();
      	factoryBean.setDataSource(this.dataSource);
      	return factoryBean.getObject();
      }
      ...
      

      Same for the next snippet in the same section. Do you agree?

      Section 1.6.2

      Is the following XML snippet to register a MapJobRegistry correct?

      <bean id="jobRegistry" class="org.spr...MapJobRegistry" p:dataSource-ref="dataSource" p:tablePrefix="BATCH_"/>
      

      The MapJobRegistry does not have properties "dataSource" and "tablePrefix". I guess this is a copy/paste from the snippet of the previous section "JobExplorer".

      In the same section 1.6.2, the following Java snippet has an extra "new":

      ...
      // This is already provided via the @EnableBatchProcessing but can be customized via
      // overriding the getter in the SimpleBatchConfiguration
      @Override
      @Bean
      public JobRegistry jobRegistry() throws Exception {
      	return new new MapJobRegistry();
      }
      ...
      

      In the same section 1.6.2, this time for AutomaticJobRegistrar, the following Java snippet is incomplete:

      ----
      @Bean
      public AutomaticJobRegistrar registrar() {
      
          AutomaticJobRegistrar registrar = new AutomaticJobRegistrar();
      
      ----
      

      In order to make it consistent with the XML example, I think it should be updated as follows:

      ----
      @Bean
      public AutomaticJobRegistrar registrar() {
      
          AutomaticJobRegistrar registrar = new AutomaticJobRegistrar();
          registrar.setJobLoader(jobLoader());
          registrar.setApplicationContextFactories(applicationContextFactories());
          registrar.afterPropertiesSet();
          return registrar;
      
      }
      ----
      

      Is this correct?

        Attachments

          Activity

            People

            • Assignee:
              mbenhassine Mahmoud Ben Hassine
              Reporter:
              mbenhassine Mahmoud Ben Hassine
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: