Skip to content

Fix for the XML/Java switch regression #4355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<!-- documentation dependencies -->
<asciidoctorj-pdf.version>1.6.2</asciidoctorj-pdf.version> <!-- FIXME build failure with version 2.3.3 -->
<asciidoctorj-epub.version>1.5.1</asciidoctorj-epub.version>
<spring-asciidoctor-backends.version>0.0.4</spring-asciidoctor-backends.version>
<spring-asciidoctor-backends.version>0.0.5</spring-asciidoctor-backends.version>

<!-- plugin versions -->
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
Expand All @@ -144,7 +144,7 @@
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<flatten-maven-plugin.version>1.3.0</flatten-maven-plugin.version>
<maven-deploy-plugin.version>3.1.0</maven-deploy-plugin.version>
<asciidoctor-maven-plugin.version>2.2.2</asciidoctor-maven-plugin.version>
<asciidoctor-maven-plugin.version>2.2.3</asciidoctor-maven-plugin.version>
<maven-assembly-plugin.version>3.4.2</maven-assembly-plugin.version>
<maven-dependency-plugin.version>3.5.0</maven-dependency-plugin.version>
<maven-site-plugin.version>3.12.1</maven-site-plugin.version>
Expand Down
25 changes: 3 additions & 22 deletions spring-batch-docs/src/main/asciidoc/domain.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ global to all steps, such as restartability. The job configuration contains:
* Definition and ordering of `Step` instances.
* Whether or not the job is restartable.

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

====
[source, java, role="javaContent"]
----
@Bean
Expand All @@ -80,7 +79,6 @@ public Job footballJob(JobRepository jobRepository) {
.build();
}
----
====

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

====
[source, xml, role="xmlContent"]
----
<job id="footballJob">
Expand All @@ -98,16 +95,14 @@ following example shows:
<step id="playerSummarization"/>
</job>
----
====
endif::backend-html5[]
endif::backend-spring-html[]

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

====
[source, java]
----
@Bean
Expand All @@ -119,13 +114,11 @@ public Job footballJob(JobRepository jobRepository) {
.build();
}
----
====

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

====
[source, xml]
----
<job id="footballJob">
Expand All @@ -134,7 +127,6 @@ example shows:
<step id="playerSummarization"/>
</job>
----
====
endif::backend-pdf[]

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

[[jobParameters]]
==== JobParameters

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

====
[source, java]
----
executionContext.putLong(getKey(LINES_READ_COUNT), reader.getPosition());
----
====

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

====
[source, java]
----
if (executionContext.containsKey(getKey(LINES_READ_COUNT))) {
Expand All @@ -529,7 +519,6 @@ if (executionContext.containsKey(getKey(LINES_READ_COUNT))) {
}
}
----
====

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

====
[source, java]
----
ExecutionContext ecStep = stepExecution.getExecutionContext();
ExecutionContext ecJob = jobExecution.getExecutionContext();
//ecStep does not equal ecJob
----
====

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

====
[source, xml, role="xmlContent"]
----
<job-repository id="jobRepository"/>
----
====

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

====
[source, java]
----
public interface JobLauncher {
Expand All @@ -608,7 +592,6 @@ public JobExecution run(Job job, JobParameters jobParameters)
JobInstanceAlreadyCompleteException, JobParametersInvalidException;
}
----
====

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

====
[source, xml, role="xmlContent"]
----
<beans:beans xmlns="http://www.springframework.org/schema/batch"
Expand All @@ -669,7 +651,6 @@ xsi:schemaLocation="

</beans:beans>
----
====

[role="xmlContent"]
As long as the batch namespace has been declared, any of its elements can be used. You can find more
Expand Down
2 changes: 0 additions & 2 deletions spring-batch-docs/src/main/asciidoc/header/index-header.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
= Spring Batch - Reference Documentation

include::../attributes.adoc[]
2 changes: 2 additions & 0 deletions spring-batch-docs/src/main/asciidoc/index-single.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
:sectnums:
:onlyonetoggle: true

include::attributes.adoc[]

include::header/index-header.adoc[]

include::toggle.adoc[]
Expand Down
2 changes: 2 additions & 0 deletions spring-batch-docs/src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include::attributes.adoc[]

include::header/index-header.adoc[]

// ======================================================================================
Expand Down
Loading