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

Improve JobBuilder and StepBuilder APIs with regards to setting mandatory properties #4192

Closed
fmbenhassine opened this issue Sep 16, 2022 · 0 comments

Comments

@fmbenhassine
Copy link
Contributor

After the deprecation of JobBuilderFactory and StepBuilderFactory in #4188, JobBuilder and StepBuilder are now the main entry points to create jobs and steps. However, unlike when created by those factories, these builders do not have the mandatory job repository property set on them. This requires the user to set it manually with a chained call to .repository(jobRepository). This is error prone and can lead to runtime errors if this property is not set. The suggested enhancement is to make the API guide the user to set this property by accepting the job repository as a parameter when creating the builder, something like:

@Bean
public Job job(JobRepository jobRepository, Step step) {
--   return new JobBuilder("job").repository(jobRepository)
++   return new JobBuilder("job", jobRepository)
			.start(step)
			.build();
}

Similarly, after #4130, the transaction manager is not set on tasklet step builders by the factory anymore. Therefore, the API should guide the user to correctly create tasklet steps with the transaction manager set on them instead of relying on an error prone chained call to .transactionManager().

@fmbenhassine fmbenhassine added this to the 5.0.0-M6 milestone Sep 16, 2022
fmbenhassine referenced this issue Sep 22, 2022
This commit deprecates JobBuilderFactory and StepBuilderFactory
in favor of the respective builders they create.

It also removes the exposure of such utilities as beans in the
application context when using `@EnableBatchProcessing`.

Resolves #4188
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