Skip to content

Commit 851bf70

Browse files
Jay Bryantfmbenhassine
authored andcommitted
Fix for the XML/Java switch regression
and some other problems. Some problems cannot be fixed. See the comment for details. Partially resolves #4168
1 parent c146f80 commit 851bf70

File tree

10 files changed

+42
-195
lines changed

10 files changed

+42
-195
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<!-- documentation dependencies -->
134134
<asciidoctorj-pdf.version>1.6.2</asciidoctorj-pdf.version> <!-- FIXME build failure with version 2.3.3 -->
135135
<asciidoctorj-epub.version>1.5.1</asciidoctorj-epub.version>
136-
<spring-asciidoctor-backends.version>0.0.4</spring-asciidoctor-backends.version>
136+
<spring-asciidoctor-backends.version>0.0.5</spring-asciidoctor-backends.version>
137137

138138
<!-- plugin versions -->
139139
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
@@ -144,7 +144,7 @@
144144
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
145145
<flatten-maven-plugin.version>1.3.0</flatten-maven-plugin.version>
146146
<maven-deploy-plugin.version>3.1.0</maven-deploy-plugin.version>
147-
<asciidoctor-maven-plugin.version>2.2.2</asciidoctor-maven-plugin.version>
147+
<asciidoctor-maven-plugin.version>2.2.3</asciidoctor-maven-plugin.version>
148148
<maven-assembly-plugin.version>3.4.2</maven-assembly-plugin.version>
149149
<maven-dependency-plugin.version>3.5.0</maven-dependency-plugin.version>
150150
<maven-site-plugin.version>3.12.1</maven-site-plugin.version>

spring-batch-docs/src/main/asciidoc/domain.adoc

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@ global to all steps, such as restartability. The job configuration contains:
6060
* Definition and ordering of `Step` instances.
6161
* Whether or not the job is restartable.
6262

63-
ifdef::backend-html5[]
63+
ifdef::backend-spring-html[]
6464
[role="javaContent"]
6565
For those who use Java configuration, Spring Batch provides a default implementation of
6666
the `Job` interface in the form of the `SimpleJob` class, which creates some standard
6767
functionality on top of `Job`. When using Java-based configuration, a collection of
6868
builders is made available for the instantiation of a `Job`, as the following
6969
example shows:
7070

71-
====
7271
[source, java, role="javaContent"]
7372
----
7473
@Bean
@@ -80,7 +79,6 @@ public Job footballJob(JobRepository jobRepository) {
8079
.build();
8180
}
8281
----
83-
====
8482

8583
[role="xmlContent"]
8684
For those who use XML configuration, Spring Batch provides a default implementation of the
@@ -89,7 +87,6 @@ functionality on top of `Job`. However, the batch namespace abstracts away the n
8987
instantiate it directly. Instead, you can use the `<job>` element, as the
9088
following example shows:
9189

92-
====
9390
[source, xml, role="xmlContent"]
9491
----
9592
<job id="footballJob">
@@ -98,16 +95,14 @@ following example shows:
9895
<step id="playerSummarization"/>
9996
</job>
10097
----
101-
====
102-
endif::backend-html5[]
98+
endif::backend-spring-html[]
10399

104100
ifdef::backend-pdf[]
105101
Spring Batch provides a default implementation of the `Job` interface in the form of the
106102
`SimpleJob` class, which creates some standard functionality on top of `Job`. When using
107103
Java-based configuration, a collection of builders are made available for the
108104
instantiation of a `Job`, as the following example shows:
109105

110-
====
111106
[source, java]
112107
----
113108
@Bean
@@ -119,13 +114,11 @@ public Job footballJob(JobRepository jobRepository) {
119114
.build();
120115
}
121116
----
122-
====
123117

124118
However, when using XML configuration, the batch namespace abstracts away the need to
125119
instantiate it directly. Instead, you can use the `<job>` element, as the following
126120
example shows:
127121

128-
====
129122
[source, xml]
130123
----
131124
<job id="footballJob">
@@ -134,7 +127,6 @@ example shows:
134127
<step id="playerSummarization"/>
135128
</job>
136129
----
137-
====
138130
endif::backend-pdf[]
139131

140132
==== JobInstance
@@ -163,6 +155,7 @@ from previous executions is used. Using a new `JobInstance` means "`start from t
163155
beginning,`" and using an existing instance generally means "`start from where you left
164156
off`".
165157

158+
[[jobParameters]]
166159
==== JobParameters
167160

168161
Having discussed `JobInstance` and how it differs from `Job`, the natural question to ask
@@ -447,12 +440,10 @@ or even if the power goes out. All that is needed is to put the current number o
447440
read into the context, as the following example shows, and the framework does the
448441
rest:
449442

450-
====
451443
[source, java]
452444
----
453445
executionContext.putLong(getKey(LINES_READ_COUNT), reader.getPosition());
454446
----
455-
====
456447

457448
Using the `EndOfDay` example from the `Job` stereotypes section as an example, assume there
458449
is one step, `loadData`, that loads a file into the database. After the first failed run,
@@ -513,7 +504,6 @@ the last run are reconstituted from the database. When the `ItemReader` is opene
513504
check to see if it has any stored state in the context and initialize itself from there,
514505
as the following example shows:
515506

516-
====
517507
[source, java]
518508
----
519509
if (executionContext.containsKey(getKey(LINES_READ_COUNT))) {
@@ -529,7 +519,6 @@ if (executionContext.containsKey(getKey(LINES_READ_COUNT))) {
529519
}
530520
}
531521
----
532-
====
533522

534523
In this case, after the preceding code runs, the current line is 40,322, letting the `Step`
535524
start again from where it left off. You can also use the `ExecutionContext` for
@@ -557,14 +546,12 @@ Note that there is at least one `ExecutionContext` per
557546
`JobExecution` and one for every `StepExecution`. For example, consider the following
558547
code snippet:
559548

560-
====
561549
[source, java]
562550
----
563551
ExecutionContext ecStep = stepExecution.getExecutionContext();
564552
ExecutionContext ecJob = jobExecution.getExecutionContext();
565553
//ecStep does not equal ecJob
566554
----
567-
====
568555

569556
As noted in the comment, `ecStep` does not equal `ecJob`. They are two different
570557
`ExecutionContexts`. The one scoped to the `Step` is saved at every commit point in the
@@ -582,12 +569,10 @@ by passing them to the repository.
582569
The Spring Batch XML namespace provides support for configuring a `JobRepository` instance
583570
with the `<job-repository>` tag, as the following example shows:
584571

585-
====
586572
[source, xml, role="xmlContent"]
587573
----
588574
<job-repository id="jobRepository"/>
589575
----
590-
====
591576

592577
[role="javaContent"]
593578
When using Java configuration, the `@EnableBatchProcessing` annotation provides a
@@ -598,7 +583,6 @@ When using Java configuration, the `@EnableBatchProcessing` annotation provides
598583
`JobLauncher` represents a simple interface for launching a `Job` with a given set of
599584
`JobParameters`, as the following example shows:
600585

601-
====
602586
[source, java]
603587
----
604588
public interface JobLauncher {
@@ -608,7 +592,6 @@ public JobExecution run(Job job, JobParameters jobParameters)
608592
JobInstanceAlreadyCompleteException, JobParametersInvalidException;
609593
}
610594
----
611-
====
612595

613596
It is expected that implementations obtain a valid `JobExecution` from the
614597
`JobRepository` and execute the `Job`.
@@ -647,7 +630,6 @@ Many of the domain concepts listed previously need to be configured in a Spring
647630
use in a standard bean definition, a namespace has been provided for ease of
648631
configuration, as the following example shows:
649632

650-
====
651633
[source, xml, role="xmlContent"]
652634
----
653635
<beans:beans xmlns="http://www.springframework.org/schema/batch"
@@ -669,7 +651,6 @@ xsi:schemaLocation="
669651
670652
</beans:beans>
671653
----
672-
====
673654

674655
[role="xmlContent"]
675656
As long as the batch namespace has been declared, any of its elements can be used. You can find more
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
= Spring Batch - Reference Documentation
2-
3-
include::../attributes.adoc[]

spring-batch-docs/src/main/asciidoc/index-single.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
:sectnums:
55
:onlyonetoggle: true
66

7+
include::attributes.adoc[]
8+
79
include::header/index-header.adoc[]
810

911
include::toggle.adoc[]

spring-batch-docs/src/main/asciidoc/index.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include::attributes.adoc[]
2+
13
include::header/index-header.adoc[]
24

35
// ======================================================================================

0 commit comments

Comments
 (0)