@@ -48,7 +48,7 @@ public Job footballJob(JobRepository jobRepository) {
48
48
49
49
[role="javaContent"]
50
50
A `Job` (and, typically, any `Step` within it) requires a `JobRepository`. The
51
- configuration of the `JobRepository` is handled through the <<job.adoc#javaConfig,`BatchConfigurer `>>.
51
+ configuration of the `JobRepository` is handled through the <<job.adoc#javaConfig,`Java Configuration `>>.
52
52
53
53
[role="javaContent"]
54
54
The preceding example illustrates a `Job` that consists of three `Step` instances. The job related
@@ -444,13 +444,14 @@ annotation and two builders.
444
444
445
445
The `@EnableBatchProcessing` annotation works similarly to the other `@Enable*` annotations in the
446
446
Spring family. In this case, `@EnableBatchProcessing` provides a base configuration for
447
- building batch jobs. Within this base configuration, an instance of `StepScope` and `Jobscope ` are
447
+ building batch jobs. Within this base configuration, an instance of `StepScope` and `JobScope ` are
448
448
created, in addition to a number of beans being made available to be autowired:
449
449
450
450
* `JobRepository`: a bean named `jobRepository`
451
451
* `JobLauncher`: a bean named `jobLauncher`
452
452
* `JobRegistry`: a bean named `jobRegistry`
453
453
* `JobExplorer`: a bean named `jobExplorer`
454
+ * `JobOperator`: a bean named `jobOperator`
454
455
455
456
The default implementation provides the beans mentioned in the preceding list and requires a `DataSource`
456
457
and a `PlatformTransactionManager` to be provided as beans within the context. The data source and transaction
@@ -1313,9 +1314,9 @@ The following example shows how to configure a `JobExplorer` in Java:
1313
1314
[source, java, role="javaContent"]
1314
1315
----
1315
1316
...
1316
- // This would reside in your BatchConfigurer implementation
1317
- @Override
1318
- public JobExplorer getJobExplorer () throws Exception {
1317
+ // This would reside in your DefaultBatchConfiguration extension
1318
+ @Bean
1319
+ public JobExplorer jobExplorer () throws Exception {
1319
1320
JobExplorerFactoryBean factoryBean = new JobExplorerFactoryBean();
1320
1321
factoryBean.setDataSource(this.dataSource);
1321
1322
return factoryBean.getObject();
@@ -1348,9 +1349,9 @@ The following example shows how to set the table prefix for a `JobExplorer` in J
1348
1349
[source, java, role="javaContent"]
1349
1350
----
1350
1351
...
1351
- // This would reside in your BatchConfigurer implementation
1352
- @Override
1353
- public JobExplorer getJobExplorer () throws Exception {
1352
+ // This would reside in your DefaultBatchConfiguration extension
1353
+ @Bean
1354
+ public JobExplorer jobExplorer () throws Exception {
1354
1355
JobExplorerFactoryBean factoryBean = new JobExplorerFactoryBean();
1355
1356
factoryBean.setDataSource(this.dataSource);
1356
1357
factoryBean.setTablePrefix("SYSTEM.");
@@ -1389,7 +1390,7 @@ The following example shows how to configure your own `JobRegistry`:
1389
1390
----
1390
1391
...
1391
1392
// This is already provided via the @EnableBatchProcessing but can be customized via
1392
- // overriding the getter in the SimpleBatchConfiguration
1393
+ // overriding the bean in the DefaultBatchConfiguration
1393
1394
@Override
1394
1395
@Bean
1395
1396
public JobRegistry jobRegistry() throws Exception {
@@ -1430,9 +1431,9 @@ defined in Java:
1430
1431
[source, java, role="javaContent"]
1431
1432
----
1432
1433
@Bean
1433
- public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor() {
1434
+ public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor(JobRegistry jobRegistry ) {
1434
1435
JobRegistryBeanPostProcessor postProcessor = new JobRegistryBeanPostProcessor();
1435
- postProcessor.setJobRegistry(jobRegistry() );
1436
+ postProcessor.setJobRegistry(jobRegistry);
1436
1437
return postProcessor;
1437
1438
}
1438
1439
----
@@ -1615,7 +1616,6 @@ The following example shows a typical bean definition for `SimpleJobOperator` in
1615
1616
JobLauncher jobLauncher) {
1616
1617
1617
1618
SimpleJobOperator jobOperator = new SimpleJobOperator();
1618
-
1619
1619
jobOperator.setJobExplorer(jobExplorer);
1620
1620
jobOperator.setJobRepository(jobRepository);
1621
1621
jobOperator.setJobRegistry(jobRegistry);
@@ -1626,6 +1626,9 @@ The following example shows a typical bean definition for `SimpleJobOperator` in
1626
1626
----
1627
1627
====
1628
1628
1629
+ As of version 5.0, the `@EnableBatchProcessing` annotation automatically registers a job operator bean
1630
+ in the application context.
1631
+
1629
1632
NOTE: If you set the table prefix on the job repository, do not forget to set it on the job explorer as well.
1630
1633
1631
1634
[[JobParametersIncrementer]]
0 commit comments