Skip to content

Commit 9307c87

Browse files
fmbenhassinemminella
authored andcommitted
Polish documentation by fixing some typos, code examples and formatting issues
1 parent 532225e commit 9307c87

13 files changed

+387
-356
lines changed

spring-batch-docs/asciidoc/appendix.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
|AmqpItemWriter|Given a Spring `AmqpTemplate`, it provides
7979
for a synchronous `send` method. The `convertAndSend(Object)`
8080
method lets you send POJO objects.
81-
|CompositeItemWriter|Passes an item to the `process` method of each
81+
|CompositeItemWriter|Passes an item to the `write` method of each
8282
in an injected `List` of `ItemWriter` objects.
8383
|FlatFileItemWriter|Writes to a flat file. Includes `ItemStream` and
8484
Skippable functionality. See link:readersAndWriters.html#flatFileItemWriter[`FlatFileItemWriter`].
@@ -116,7 +116,7 @@
116116
names.
117117
|RepositoryItemWriter|Given a Spring Data `CrudRepository` implementation,
118118
items are saved through the method specified in the configuration.
119-
|StaxEventItemWriter|Uses an `ObjectToXmlSerializer` implementation to
119+
|StaxEventItemWriter|Uses a `Marshaller` implementation to
120120
convert each item to XML and then writes it to an XML file using
121121
StAX.
122122

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

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public class ItemFailureLoggerListener extends ItemListenerSupport {
4444
logger.error("Encountered error on read", e);
4545
}
4646
47-
public void onWriteError(Exception ex, Object item) {
47+
public void onWriteError(Exception ex, List<? extends Object> items) {
4848
logger.error("Encountered error on write", ex);
4949
}
5050
}
5151
----
5252

53-
Having implemented this listener it, must be registered with a step, as shown in the
53+
Having implemented this listener, it must be registered with a step, as shown in the
5454
following example:
5555

5656
.XML Configuration
@@ -78,7 +78,7 @@ public Step simpleStep() {
7878
}
7979
----
8080

81-
Remember that, if your listener does anything in an `onError()` method, it must be inside
81+
NOTE: if your listener does anything in an `onError()` method, it must be inside
8282
a transaction that is going to be rolled back. If you need to use a transactional
8383
resource, such as a database, inside an `onError()` method, consider adding a declarative
8484
transaction to that method (see Spring Core Reference Guide for details), and giving its
@@ -98,12 +98,14 @@ in the following example:
9898

9999
[source, java]
100100
----
101-
public class PoisonPillItemWriter implements ItemWriter<T> {
101+
public class PoisonPillItemProcessor<T> implements ItemProcessor<T, T> {
102102
103-
public void write(T item) throws Exception {
103+
@Override
104+
public T process(T item) throws Exception {
104105
if (isPoisonPill(item)) {
105106
throw new PoisonPillException("Poison pill detected: " + item);
106-
}
107+
}
108+
return item;
107109
}
108110
}
109111
----
@@ -259,7 +261,7 @@ public class TradeItemWriter implements ItemWriter<Trade>,
259261
260262
private BigDecimal totalAmount = BigDecimal.ZERO;
261263
262-
public void write(List<? extends Trade> items) {
264+
public void write(List<? extends Trade> items) throws Exception {
263265
BigDecimal chunkTotal = BigDecimal.ZERO;
264266
for (Trade trade : items) {
265267
chunkTotal = chunkTotal.add(trade.getAmount());
@@ -282,7 +284,7 @@ public class TradeItemWriter implements ItemWriter<Trade>,
282284
This `TradeItemWriter` stores a `totalAmount` value that is increased with the `amount`
283285
from each `Trade` item written. After the last `Trade` is processed, the framework calls
284286
`writeFooter`, which puts the `totalAmount` into the file. Note that the `write` method
285-
makes use of a temporary variable, `chunkTotalAmount`, that stores the total of the
287+
makes use of a temporary variable, `chunkTotal`, that stores the total of the
286288
`Trade` amounts in the chunk. This is done to ensure that, if a skip occurs in the
287289
`write` method, the `totalAmount` is left unchanged. It is only at the end of the `write`
288290
method, once we are guaranteed that no exceptions are thrown, that we update the
@@ -384,7 +386,7 @@ into a full 'Foo' object. An existing DAO can be used to query for the full obje
384386
on the key.
385387

386388
[[multiLineRecords]]
387-
==== Multi-Line Records
389+
=== Multi-Line Records
388390

389391
While it is usually the case with flat files that each record is confined to a single
390392
line, it is common that a file might have records spanning multiple lines with multiple
@@ -419,9 +421,7 @@ do this, a custom `ItemReader` should be implemented as a wrapper for the
419421
<property name="lineMapper">
420422
<bean class="org.spr...DefaultLineMapper">
421423
<property name="lineTokenizer" ref="orderFileTokenizer"/>
422-
<property name="fieldSetMapper">
423-
<bean class="org.spr...PassThroughFieldSetMapper" />
424-
</property>
424+
<property name="fieldSetMapper" ref="orderFieldSetMapper"/>
425425
</bean>
426426
</property>
427427
</bean>
@@ -445,10 +445,11 @@ public MultiLineTradeItemReader itemReader() {
445445
public FlatFileItemReader flatFileItemReader() {
446446
FlatFileItemReader<Trade> reader = new FlatFileItemReaderBuilder<Trade>()
447447
.name("flatFileItemReader")
448-
.resource(new ClasspathResource("data/iosample/input/multiLine.txt"))
448+
.resource(new ClassPathResource("data/iosample/input/multiLine.txt"))
449449
.lineTokenizer(orderFileTokenizer())
450-
.fieldSetMapper(new PassThroughFieldSetMapper())
450+
.fieldSetMapper(orderFieldSetMapper())
451451
.build();
452+
return reader;
452453
}
453454
----
454455

@@ -490,7 +491,7 @@ public PatternMatchingCompositeLineTokenizer orderFileTokenizer() {
490491
tokenizers.put("NCU*", customerLineTokenizer());
491492
tokenizers.put("BAD*", billingAddressLineTokenizer());
492493
493-
tokenizer.setTokenizers(tokenizers());
494+
tokenizer.setTokenizers(tokenizers);
494495
495496
return tokenizer;
496497
}
@@ -578,11 +579,11 @@ exceptional. The `Step` is simply considered to have found no work and completes
578579
items read. All of the `ItemReader` implementations provided out of the box in Spring
579580
Batch default to this approach. This can lead to some confusion if nothing is written out
580581
even when input is present (which usually happens if a file was misnamed or some similar
581-
issue arises) For this reason, the metadata itself should be inspected to determine how
582+
issue arises). For this reason, the metadata itself should be inspected to determine how
582583
much work the framework found to be processed. However, what if finding no input is
583584
considered exceptional? In this case, programmatically checking the metadata for no items
584585
processed and causing failure is the best solution. Because this is a common use case,
585-
Spring Batch provides a listener is provided with exactly this functionality, as shown in
586+
Spring Batch provides a listener with exactly this functionality, as shown in
586587
the class definition for `NoWorkFoundStepExecutionListener`:
587588

588589
[source, java]
@@ -644,7 +645,7 @@ To make the data available to future `Steps`, it must be "promoted" to the `Job`
644645
with the keys related to the data in the `ExecutionContext` that must be promoted. It can
645646
also, optionally, be configured with a list of exit code patterns for which the promotion
646647
should occur (`COMPLETED` is the default). As with all listeners, it must be registered
647-
on the`Step` as shown in the following example:
648+
on the `Step` as shown in the following example:
648649

649650
.XML Configuration
650651
[source, xml, role="xmlContent"]
@@ -665,7 +666,11 @@ on the`Step` as shown in the following example:
665666
</job>
666667
667668
<beans:bean id="promotionListener" class="org.spr....ExecutionContextPromotionListener">
668-
<beans:property name="keys" value="someKey"/>
669+
<beans:property name="keys">
670+
<list>
671+
<value>someKey</value>
672+
</list>
673+
</beans:property>
669674
</beans:bean>
670675
----
671676

@@ -677,7 +682,6 @@ public Job job1() {
677682
return this.jobBuilderFactory.get("job1")
678683
.start(step1())
679684
.next(step1())
680-
.end()
681685
.build();
682686
}
683687
@@ -695,7 +699,7 @@ public Step step1() {
695699
public ExecutionContextPromotionListener promotionListener() {
696700
ExecutionContextPromotionListener listener = new ExecutionContextPromotionListener();
697701
698-
listener.setKeys("someKey");
702+
listener.setKeys(new String[] {"someKey" });
699703
700704
return listener;
701705
}

spring-batch-docs/asciidoc/domain.adoc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ image::{batch-asciidoc}images/job-stereotypes-parameters.png[Job Parameters, sca
170170
In the preceding example, where there are two instances, one for January 1st, and another
171171
for January 2nd, there is really only one `Job`, but it has two `JobParameter` objects:
172172
one that was started with a job parameter of 01-01-2017 and another that was started with
173-
a parameter of 01-02-2017. Thus, the contract can be defined as: `JobInstance` = `Job` +
174-
identifying `JobParameters`. This allows a developer to effectively control how a
173+
a parameter of 01-02-2017. Thus, the contract can be defined as: `JobInstance` = `Job`
174+
+ identifying `JobParameters`. This allows a developer to effectively control how a
175175
`JobInstance` is defined, since they control what parameters are passed in.
176176

177177
NOTE: Not all job parameters are required to contribute to the identification of a
@@ -384,12 +384,12 @@ finishes successfully, the status is `BatchStatus.COMPLETED`.
384384

385385
|startTime
386386
|A `java.util.Date` representing the current system time when the execution was started.
387-
This field is empty if the job has yet to start.
387+
This field is empty if the step has yet to start.
388388

389389
|endTime
390390

391391
|A `java.util.Date` representing the current system time when the execution finished,
392-
regardless of whether or not it was successful. This field is empty if the job has yet to
392+
regardless of whether or not it was successful. This field is empty if the step has yet to
393393
exit.
394394

395395
|exitStatus
@@ -456,7 +456,7 @@ the metadata tables would look like the following example:
456456
|EndOfDayJob
457457
|===
458458

459-
.BATCH_JOB_PARAMS
459+
.BATCH_JOB_EXECUTION_PARAMS
460460
|===
461461
|JOB_INST_ID|TYPE_CD|KEY_NAME|DATE_VAL
462462
|1
@@ -587,7 +587,8 @@ When using java configuration, `@EnableBatchProcessing` annotation provides a
587587
public interface JobLauncher {
588588
589589
public JobExecution run(Job job, JobParameters jobParameters)
590-
throws JobExecutionAlreadyRunningException, JobRestartException;
590+
throws JobExecutionAlreadyRunningException, JobRestartException,
591+
JobInstanceAlreadyCompleteException, JobParametersInvalidException;
591592
}
592593
----
593594
It is expected that implementations obtain a valid `JobExecution` from the

0 commit comments

Comments
 (0)