Skip to content

Commit efdce56

Browse files
Jay Bryantfmbenhassine
Jay Bryant
authored andcommitted
Made the "Both" option make sense
I edited the leader paragraphs above each code block that was flagged as being XML or Java content, such that the paragraphs make sense when both the XML and the Java blocks are present. I turned the Both button back on. I also caught a bunch of other editing things. Mahmoud Ben Hassine caught a couple of sentences that were problematic when the Both option is on. I then caught a couple of other problems. I fixed all of that. Thanks for reading closely, Mahmoud. I always appreciate that.
1 parent ae6cd59 commit efdce56

13 files changed

+1526
-1225
lines changed

spring-batch-docs/asciidoc/common-patterns.adoc

+60-13
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ public class ItemFailureLoggerListener extends ItemListenerSupport {
5050
}
5151
----
5252

53-
Having implemented this listener, it must be registered with a step, as shown in the
54-
following example:
53+
Having implemented this listener, it must be registered with a step.
54+
55+
[role="xmlContent"]
56+
The following example shows how to register a listener with a step in XML:
5557

5658
.XML Configuration
5759
[source, xml, role="xmlContent"]
@@ -66,6 +68,9 @@ following example:
6668
</step>
6769
----
6870

71+
[role="javaContent"]
72+
The following example shows how to register a listener with a step Java:
73+
6974
.Java Configuration
7075
[source, java, role="javaContent"]
7176
----
@@ -134,8 +139,10 @@ public class EarlyCompletionItemReader implements ItemReader<T> {
134139
The previous example actually relies on the fact that there is a default implementation
135140
of the `CompletionPolicy` strategy that signals a complete batch when the item to be
136141
processed is `null`. A more sophisticated completion policy could be implemented and
137-
injected into the `Step` through the `SimpleStepFactoryBean`, as shown in the following
138-
example:
142+
injected into the `Step` through the `SimpleStepFactoryBean`.
143+
144+
[role="xmlContent"]
145+
The following example shows how to inject a completion policy into a step in XML:
139146

140147
.XML Configuration
141148
[source, xml, role="xmlContent"]
@@ -150,6 +157,9 @@ example:
150157
<bean id="completionPolicy" class="org.example...SpecialCompletionPolicy"/>
151158
----
152159

160+
[role="javaContent"]
161+
The following example shows how to inject a completion policy into a step in Java:
162+
153163
.Java Configuration
154164
[source, java, role="javaContent"]
155165
----
@@ -196,12 +206,15 @@ so this is always an abnormal ending to a job.
196206
[[addingAFooterRecord]]
197207
=== Adding a Footer Record
198208

199-
Often, when writing to flat files, a "footer" record must be appended to the end of the
209+
Often, when writing to flat files, a "`footer`" record must be appended to the end of the
200210
file, after all processing has be completed. This can be achieved using the
201211
`FlatFileFooterCallback` interface provided by Spring Batch. The `FlatFileFooterCallback`
202212
(and its counterpart, the `FlatFileHeaderCallback`) are optional properties of the
203-
`FlatFileItemWriter` and can be added to an item writer as shown in the following
204-
example:
213+
`FlatFileItemWriter` and can be added to an item writer.
214+
215+
[role="xmlContent"]
216+
The following example shows how to use the `FlatFileHeaderCallback` and the
217+
`FlatFileFooterCallback` in XML:
205218

206219
.XML Configuration
207220
[source, xml, role="xmlContent"]
@@ -214,6 +227,10 @@ example:
214227
</bean>
215228
----
216229

230+
[role="javaContent"]
231+
The following example shows how to use the `FlatFileHeaderCallback` and the
232+
`FlatFileFooterCallback` in Java:
233+
217234
.Java Configuration
218235
[source, java, role="javaContent"]
219236
----
@@ -292,7 +309,10 @@ method, once we are guaranteed that no exceptions are thrown, that we update the
292309

293310
In order for the `writeFooter` method to be called, the `TradeItemWriter` (which
294311
implements `FlatFileFooterCallback`) must be wired into the `FlatFileItemWriter` as the
295-
`footerCallback`. The following example shows how to do so:
312+
`footerCallback`.
313+
314+
[role="xmlContent"]
315+
The following example shows how to wire the `TradeItemWriter` in XML:
296316

297317
.XML Configuration
298318
[source, xml, role="xmlContent"]
@@ -308,6 +328,9 @@ implements `FlatFileFooterCallback`) must be wired into the `FlatFileItemWriter`
308328
</bean>
309329
----
310330

331+
[role="javaContent"]
332+
The following example shows how to wire the `TradeItemWriter` in Java:
333+
311334
.Java Configuration
312335
[source, java, role="javaContent"]
313336
----
@@ -409,7 +432,10 @@ multi-line record as a group, so that it can be passed to the `ItemWriter` intac
409432
Because a single record spans multiple lines and because we may not know how many lines
410433
there are, the `ItemReader` must be careful to always read an entire record. In order to
411434
do this, a custom `ItemReader` should be implemented as a wrapper for the
412-
`FlatFileItemReader`, as shown in the following example:
435+
`FlatFileItemReader`.
436+
437+
[role="xmlContent"]
438+
The following example shows how to implement a custom `ItemReader` in XML:
413439

414440
.XML Configuration
415441
[source, xml, role="xmlContent"]
@@ -429,6 +455,9 @@ do this, a custom `ItemReader` should be implemented as a wrapper for the
429455
</bean>
430456
----
431457

458+
[role="javaContent"]
459+
The following example shows how to implement a custom `ItemReader` in Java:
460+
432461
.Java Configuration
433462
[source, java, role="javaContent"]
434463
----
@@ -459,7 +488,10 @@ delegate `FlatFileItemReader`. See
459488
link:readersAndWriters.html#flatFileItemReader[`FlatFileItemReader` in the Readers and
460489
Writers chapter] for more details. The delegate reader then uses a
461490
`PassThroughFieldSetMapper` to deliver a `FieldSet` for each line back to the wrapping
462-
`ItemReader`, as shown in the following example:
491+
`ItemReader`.
492+
493+
[role="xmlContent"]
494+
The following example shows how to ensure that each line is properly tokenized in XML:
463495

464496
.XML Content
465497
[source, xml, role="xmlContent"]
@@ -476,6 +508,9 @@ Writers chapter] for more details. The delegate reader then uses a
476508
</bean>
477509
----
478510

511+
[role="javaContent"]
512+
The following example shows how to ensure that each line is properly tokenized in Java:
513+
479514
.Java Content
480515
[source, java, role="javaContent"]
481516
----
@@ -545,7 +580,10 @@ common metadata about the run would be lost. Furthermore, a multi-step job would
545580
need to be split up into multiple jobs as well.
546581

547582
Because the need is so common, Spring Batch provides a `Tasklet` implementation for
548-
calling system commands, as shown in the following example:
583+
calling system commands.
584+
585+
[role="xmlContent"]
586+
The following example shows how to call an external command in XML:
549587

550588
.XML Configuration
551589
[source, xml, role="xmlContent"]
@@ -557,6 +595,9 @@ calling system commands, as shown in the following example:
557595
</bean>
558596
----
559597

598+
[role="javaContent"]
599+
The following example shows how to call an external command in Java:
600+
560601
.Java Configuration
561602
[source, java, role="javaContent"]
562603
----
@@ -639,13 +680,16 @@ public class SavingItemWriter implements ItemWriter<Object> {
639680
}
640681
----
641682

642-
To make the data available to future `Steps`, it must be "promoted" to the `Job`
683+
To make the data available to future `Steps`, it must be "`promoted`" to the `Job`
643684
`ExecutionContext` after the step has finished. Spring Batch provides the
644685
`ExecutionContextPromotionListener` for this purpose. The listener must be configured
645686
with the keys related to the data in the `ExecutionContext` that must be promoted. It can
646687
also, optionally, be configured with a list of exit code patterns for which the promotion
647688
should occur (`COMPLETED` is the default). As with all listeners, it must be registered
648-
on the `Step` as shown in the following example:
689+
on the `Step`.
690+
691+
[role="xmlContent"]
692+
The following example shows how to promote a step to the `Job` `ExecutionContext` in XML:
649693

650694
.XML Configuration
651695
[source, xml, role="xmlContent"]
@@ -674,6 +718,9 @@ on the `Step` as shown in the following example:
674718
</beans:bean>
675719
----
676720

721+
[role="xmlContent"]
722+
The following example shows how to promote a step to the `Job` `ExecutionContext` in Java:
723+
677724
.Java Configuration
678725
[source, java, role="javaContent"]
679726
----

spring-batch-docs/asciidoc/domain.adoc

+16-14
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ global to all steps, such as restartability. The job configuration contains:
6363

6464
ifdef::backend-html5[]
6565
[role="javaContent"]
66-
A default simple implementation of the Job interface is provided by Spring Batch in the
67-
form of the `SimpleJob` class, which creates some standard functionality on top of `Job`.
68-
When using java based configuration, a collection of builders is made available for the
69-
instantiation of a `Job`, as shown in the following example:
66+
For those who use Java configuration, Spring Batch provices a default implementation of
67+
the Job interface in the form of the `SimpleJob` class, which creates some standard
68+
functionality on top of `Job`. When using java based configuration, a collection of
69+
builders is made available for the instantiation of a `Job`, as shown in the following
70+
example:
7071

7172
[source, java, role="javaContent"]
7273
----
@@ -82,10 +83,11 @@ public Job footballJob() {
8283
----
8384

8485
[role="xmlContent"]
85-
A default simple implementation of the `Job` interface is provided by Spring Batch in the
86-
form of the `SimpleJob` class, which creates some standard functionality on top of `Job`.
87-
However, the batch namespace abstracts away the need to instantiate it directly. Instead,
88-
the `<job>` tag can be used as shown in the following example:
86+
For those who use XML configuration, Spring Batch provides a default implementation of the
87+
`Job` interface in the form of the `SimpleJob` class, which creates some standard
88+
functionality on top of `Job`. However, the batch namespace abstracts away the need to
89+
instantiate it directly. Instead, the `<job>` element can be used, as shown in the
90+
following example:
8991

9092
[source, xml, role="xmlContent"]
9193
----
@@ -98,9 +100,9 @@ the `<job>` tag can be used as shown in the following example:
98100
endif::backend-html5[]
99101

100102
ifdef::backend-pdf[]
101-
A default simple implementation of the Job interface is provided by Spring Batch in the
102-
form of the `SimpleJob` class, which creates some standard functionality on top of `Job`.
103-
When using java based configuration, a collection of builders are made available for the
103+
Spring Batch provides a default implementation of the Job interface in the form of the
104+
`SimpleJob` class, which creates some standard functionality on top of `Job`. When using
105+
Java-based configuration, a collection of builders are made available for the
104106
instantiation of a `Job`, as shown in the following example:
105107

106108
[source, java]
@@ -565,16 +567,16 @@ the course of execution, `StepExecution` and `JobExecution` implementations are
565567
by passing them to the repository.
566568

567569
[role="xmlContent"]
568-
The batch namespace provides support for configuring a `JobRepository` instance with the
569-
`<job-repository>` tag, as shown in the following example:
570+
The Spring Batch XML namespace provides support for configuring a `JobRepository` instance
571+
with the `<job-repository>` tag, as shown in the following example:
570572

571573
[source, xml, role="xmlContent"]
572574
----
573575
<job-repository id="jobRepository"/>
574576
----
575577

576578
[role="javaContent"]
577-
When using java configuration, `@EnableBatchProcessing` annotation provides a
579+
When using Java configuration, the `@EnableBatchProcessing` annotation provides a
578580
`JobRepository` as one of the components automatically configured out of the box.
579581

580582
=== JobLauncher

0 commit comments

Comments
 (0)