From be517d0afb1db2bd9a8e75c338613cbb21e5e624 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Fri, 13 Jul 2018 16:33:13 +0200 Subject: [PATCH] Add documentation about how to provide a custom `BatchConfigurer` Resolves BATCH-2724 --- spring-batch-docs/asciidoc/job.adoc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/spring-batch-docs/asciidoc/job.adoc b/spring-batch-docs/asciidoc/job.adoc index c27293ec1a..4e905e9e32 100644 --- a/spring-batch-docs/asciidoc/job.adoc +++ b/spring-batch-docs/asciidoc/job.adoc @@ -450,8 +450,25 @@ The `@EnableBatchProcessing` works similarly to the other The core interface for this configuration is the `BatchConfigurer`. The default implementation provides the beans mentioned above and requires a `DataSource` as a bean within the context to be provided. This data - source will be used by the JobRepository. + source will be used by the JobRepository. You can customize any of these beans + by creating a custom implementation of the `BatchConfigurer` interface. + Typically, extending the `DefaultBatchConfigurer` (which is provided if a + `BatchConfigurer` is not found) and overriding the required getter is sufficient. + However, implementing your own from scratch may be required. The following + example shows how to provide a custom transaction manager: +[source, java] +---- +@Bean +public BatchConfigurer batchConfigurer() { + return new DefaultBatchConfigurer() { + @Override + public PlatformTransactionManager getTransactionManager() { + return new MyTransactionManager(); + } + }; +} +---- [NOTE]