Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect code examples in "Configuring and Running a Job" documentation [BATCH-2669] #935

Closed
spring-projects-issues opened this issue Jan 8, 2018 · 0 comments

Comments

@spring-projects-issues
Copy link
Collaborator

Mahmoud Ben Hassine opened BATCH-2669 and commented

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?


Affects: 4.0.0

Referenced from: pull request #563, and commits 020d051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant