2
2
[[domainLanguageOfBatch]]
3
3
= The Domain Language of Batch
4
4
5
- ifndef::onlyonetoggle[]
6
- endif::onlyonetoggle[]
7
5
8
6
To any experienced batch architect, the overall concepts of batch processing used in
9
7
Spring Batch should be familiar and comfortable. There are "`Jobs`" and "`Steps`" and
@@ -57,15 +55,18 @@ global to all steps, such as restartability. The job configuration contains:
57
55
* Definition and ordering of `Step` instances.
58
56
* Whether or not the job is restartable.
59
57
60
- ifdef::backend-spring-html[]
61
- [role="javaContent"]
58
+
59
+ [tabs]
60
+ ====
61
+ Java::
62
+ +
62
63
For those who use Java configuration, Spring Batch provides a default implementation of
63
64
the `Job` interface in the form of the `SimpleJob` class, which creates some standard
64
65
functionality on top of `Job`. When using Java-based configuration, a collection of
65
66
builders is made available for the instantiation of a `Job`, as the following
66
67
example shows:
67
-
68
- [source, java, role="javaContent" ]
68
+ +
69
+ [source, java]
69
70
----
70
71
@Bean
71
72
public Job footballJob(JobRepository jobRepository) {
@@ -77,54 +78,28 @@ public Job footballJob(JobRepository jobRepository) {
77
78
}
78
79
----
79
80
80
- [role="xmlContent"]
81
+ XML::
82
+ +
81
83
For those who use XML configuration, Spring Batch provides a default implementation of the
82
84
`Job` interface in the form of the `SimpleJob` class, which creates some standard
83
85
functionality on top of `Job`. However, the batch namespace abstracts away the need to
84
86
instantiate it directly. Instead, you can use the `<job>` element, as the
85
87
following example shows:
86
-
87
- [source, xml, role="xmlContent" ]
88
+ +
89
+ [source, xml]
88
90
----
89
91
<job id="footballJob">
90
92
<step id="playerload" next="gameLoad"/>
91
93
<step id="gameLoad" next="playerSummarization"/>
92
94
<step id="playerSummarization"/>
93
95
</job>
94
96
----
95
- endif::backend-spring-html[]
96
97
97
- ifdef::backend-pdf[]
98
- Spring Batch provides a default implementation of the `Job` interface in the form of the
99
- `SimpleJob` class, which creates some standard functionality on top of `Job`. When using
100
- Java-based configuration, a collection of builders are made available for the
101
- instantiation of a `Job`, as the following example shows:
98
+ ====
99
+
102
100
103
- [source, java]
104
- ----
105
- @Bean
106
- public Job footballJob(JobRepository jobRepository) {
107
- return new JobBuilder("footballJob", jobRepository)
108
- .start(playerLoad())
109
- .next(gameLoad())
110
- .next(playerSummarization())
111
- .build();
112
- }
113
- ----
114
101
115
- However, when using XML configuration, the batch namespace abstracts away the need to
116
- instantiate it directly. Instead, you can use the `<job>` element, as the following
117
- example shows:
118
102
119
- [source, xml]
120
- ----
121
- <job id="footballJob">
122
- <step id="playerload" next="gameLoad"/>
123
- <step id="gameLoad" next="playerSummarization"/>
124
- <step id="playerSummarization"/>
125
- </job>
126
- ----
127
- endif::backend-pdf[]
128
103
129
104
[[jobinstance]]
130
105
=== JobInstance
@@ -568,18 +543,25 @@ It provides CRUD operations for `JobLauncher`, `Job`, and `Step` implementations
568
543
the course of execution, `StepExecution` and `JobExecution` implementations are persisted
569
544
by passing them to the repository.
570
545
571
- [role="xmlContent"]
546
+
547
+ [tabs]
548
+ ====
549
+ Java::
550
+ +
551
+ When using Java configuration, the `@EnableBatchProcessing` annotation provides a
552
+ `JobRepository` as one of the components that is automatically configured.
553
+
554
+ XML::
555
+ +
572
556
The Spring Batch XML namespace provides support for configuring a `JobRepository` instance
573
557
with the `<job-repository>` tag, as the following example shows:
574
-
575
- [source, xml, role="xmlContent" ]
558
+ +
559
+ [source, xml]
576
560
----
577
561
<job-repository id="jobRepository"/>
578
562
----
563
+ ====
579
564
580
- [role="javaContent"]
581
- When using Java configuration, the `@EnableBatchProcessing` annotation provides a
582
- `JobRepository` as one of the components that is automatically configured.
583
565
584
566
[[joblauncher]]
585
567
== JobLauncher
@@ -638,6 +620,7 @@ Many of the domain concepts listed previously need to be configured in a Spring
638
620
use in a standard bean definition, a namespace has been provided for ease of
639
621
configuration, as the following example shows:
640
622
623
+
641
624
[source, xml, role="xmlContent"]
642
625
----
643
626
<beans:beans xmlns="http://www.springframework.org/schema/batch"
@@ -660,8 +643,8 @@ xsi:schemaLocation="
660
643
</beans:beans>
661
644
----
662
645
663
- [role="xmlContent"]
664
646
As long as the batch namespace has been declared, any of its elements can be used. You can find more
665
647
information on configuring a Job in xref:job.adoc[Configuring and Running a Job]
666
648
. You can find more information on configuring a `Step` in
667
649
xref:step.adoc[Configuring a Step].
650
+
0 commit comments