From c0791039dc7e2f85bf682def6d24668ea6c788f5 Mon Sep 17 00:00:00 2001 From: Marvin Deng Date: Mon, 13 Jun 2022 22:48:46 +0800 Subject: [PATCH] Rename SimpleJobLauncher to TaskExecutorJobLauncher Resolves #4123 --- .../annotation/DefaultBatchConfigurer.java | 4 +-- .../annotation/EnableBatchProcessing.java | 7 +++-- ...cher.java => TaskExecutorJobLauncher.java} | 4 +-- .../core/step/builder/JobStepBuilder.java | 4 +-- ...java => TaskExecutorJobLauncherTests.java} | 14 +++++----- .../dao/AbstractJobExecutionDaoTests.java | 4 +-- .../batch/core/step/job/JobStepTests.java | 4 +-- .../resources/applicationContext-test2.xml | 2 +- .../JobRegistryIntegrationTests-context.xml | 2 +- .../xml/JobStepParserTests-context.xml | 2 +- .../JobLauncherIntegrationTests-context.xml | 2 +- .../batch/core/partition/launch-context.xml | 2 +- .../OptimisticLockingFailureTests-context.xml | 2 +- .../dao/TablePrefixTests-context.xml | 2 +- ...stPreparedStatementSetterTests-context.xml | 2 +- .../CommitIntervalJobParameter-context.xml | 2 +- .../step/RestartInPriorStepTests-context.xml | 2 +- .../core/step/RestartLoopTests-context.xml | 2 +- ...tTolerantExceptionClassesTests-context.xml | 2 +- .../item/ScriptItemProcessorTests-context.xml | 2 +- .../skip/ReprocessExceptionTests-context.xml | 2 +- .../resources/simple-job-launcher-context.xml | 2 +- spring-batch-docs/src/main/asciidoc/job.adoc | 26 +++++++++---------- .../asciidoc/spring-batch-integration.adoc | 8 +++--- ...ltTolerantStepIntegrationTests-context.xml | 2 +- ...lerantStepJdbcIntegrationTests-context.xml | 2 +- ...olerantStepJmsIntegrationTests-context.xml | 2 +- ...emoteChunkStepIntegrationTests-context.xml | 2 +- ...JobLaunchingGatewayParserTests-context.xml | 2 +- ...chingGatewayParserTestsRunning-context.xml | 2 +- .../resources/simple-job-launcher-context.xml | 2 +- spring-batch-samples/README.md | 2 +- .../main/resources/jobs/infiniteLoopJob.xml | 2 +- .../resources/simple-job-launcher-context.xml | 2 +- .../skipSample-job-launcher-context.xml | 2 +- .../resources/simple-job-launcher-context.xml | 2 +- 36 files changed, 64 insertions(+), 65 deletions(-) rename spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/{SimpleJobLauncher.java => TaskExecutorJobLauncher.java} (98%) rename spring-batch-core/src/test/java/org/springframework/batch/core/launch/{SimpleJobLauncherTests.java => TaskExecutorJobLauncherTests.java} (96%) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java index 583d04ebf..16d96b28b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java @@ -22,7 +22,7 @@ import org.springframework.batch.core.configuration.BatchConfigurationException; import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.explore.support.JobExplorerFactoryBean; import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; import org.springframework.beans.factory.InitializingBean; @@ -133,7 +133,7 @@ public class DefaultBatchConfigurer implements BatchConfigurer, InitializingBean * creating the {@link JobLauncher}. */ protected JobLauncher createJobLauncher() throws Exception { - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(this.jobRepository); jobLauncher.afterPropertiesSet(); return jobLauncher; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java index 59edc8bb2..53184e591 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java @@ -26,10 +26,9 @@ import org.springframework.batch.core.configuration.JobRegistry; import org.springframework.batch.core.configuration.support.ApplicationContextFactory; import org.springframework.batch.core.configuration.support.AutomaticJobRegistrar; import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.beans.factory.UnsatisfiedDependencyException; import org.springframework.context.annotation.Import; -import org.springframework.transaction.PlatformTransactionManager; /** *

@@ -102,7 +101,7 @@ import org.springframework.transaction.PlatformTransactionManager; *

  • a {@link JobRepository} (bean name "jobRepository" of type * {@link org.springframework.batch.core.repository.support.SimpleJobRepository})
  • *
  • a {@link JobLauncher} (bean name "jobLauncher" of type - * {@link org.springframework.batch.core.launch.support.SimpleJobLauncher})
  • + * {@link TaskExecutorJobLauncher}) *
  • a {@link JobRegistry} (bean name "jobRegistry" of type * {@link org.springframework.batch.core.configuration.support.MapJobRegistry})
  • *
  • a {@link org.springframework.batch.core.explore.JobExplorer} (bean name @@ -190,7 +189,7 @@ import org.springframework.transaction.PlatformTransactionManager; * * * +"org.springframework.batch.core.launch.support.TaskExecutorJobLauncher"> * * * diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/TaskExecutorJobLauncher.java similarity index 98% rename from spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/TaskExecutorJobLauncher.java index 60fe460c5..3af63796f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/TaskExecutorJobLauncher.java @@ -62,9 +62,9 @@ import org.springframework.util.Assert; * @see JobRepository * @see TaskExecutor */ -public class SimpleJobLauncher implements JobLauncher, InitializingBean { +public class TaskExecutorJobLauncher implements JobLauncher, InitializingBean { - protected static final Log logger = LogFactory.getLog(SimpleJobLauncher.class); + protected static final Log logger = LogFactory.getLog(TaskExecutorJobLauncher.class); private JobRepository jobRepository; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/JobStepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/JobStepBuilder.java index f9d4609f7..a9abb9663 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/JobStepBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/JobStepBuilder.java @@ -18,7 +18,7 @@ package org.springframework.batch.core.step.builder; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.step.job.JobParametersExtractor; import org.springframework.batch.core.step.job.JobStep; @@ -93,7 +93,7 @@ public class JobStepBuilder extends StepBuilderHelper { step.setJobParametersExtractor(jobParametersExtractor); } if (jobLauncher == null) { - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(getJobRepository()); try { jobLauncher.afterPropertiesSet(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/TaskExecutorJobLauncherTests.java similarity index 96% rename from spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/launch/TaskExecutorJobLauncherTests.java index 4a9b1f5cf..55681ec9e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/TaskExecutorJobLauncherTests.java @@ -40,7 +40,7 @@ import org.springframework.batch.core.JobParametersValidator; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.DefaultJobParametersValidator; import org.springframework.batch.core.job.JobSupport; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.JobRestartException; @@ -52,9 +52,9 @@ import org.springframework.core.task.TaskRejectedException; * @author Will Schipp * */ -public class SimpleJobLauncherTests { +public class TaskExecutorJobLauncherTests { - private SimpleJobLauncher jobLauncher; + private TaskExecutorJobLauncher jobLauncher; private JobSupport job = new JobSupport("foo") { @Override @@ -71,7 +71,7 @@ public class SimpleJobLauncherTests { @Before public void setUp() throws Exception { - jobLauncher = new SimpleJobLauncher(); + jobLauncher = new TaskExecutorJobLauncher(); jobRepository = mock(JobRepository.class); jobLauncher.setJobRepository(jobRepository); @@ -233,7 +233,7 @@ public class SimpleJobLauncherTests { @Test public void testInitialiseWithoutRepository() throws Exception { try { - new SimpleJobLauncher().afterPropertiesSet(); + new TaskExecutorJobLauncher().afterPropertiesSet(); fail("Expected IllegalArgumentException"); } catch (IllegalStateException e) { @@ -245,7 +245,7 @@ public class SimpleJobLauncherTests { @Test public void testInitialiseWithRepository() throws Exception { - jobLauncher = new SimpleJobLauncher(); + jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.afterPropertiesSet(); // no error } @@ -311,7 +311,7 @@ public class SimpleJobLauncherTests { when(jobExecution.getStepExecutions()).thenReturn(Arrays.asList(stepExecution)); // setup launcher - jobLauncher = new SimpleJobLauncher(); + jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(jobRepository); // run diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java index 752dfe230..5bd288783 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java @@ -206,8 +206,8 @@ public abstract class AbstractJobExecutionDaoTests { // BATCH-2675 // Abnormal JobExecution as both StartTime and EndTime are null - // This can occur when SimpleJobLauncher#run() submission to taskExecutor throws a - // TaskRejectedException + // This can occur when TaskExecutorJobLauncher#run() submission to taskExecutor + // throws a TaskRejectedException exec = new JobExecution(jobInstance, jobParameters); exec.setLastUpdated(new Date(5L)); dao.saveJobExecution(exec); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java index c8642e451..1e8563452 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java @@ -27,7 +27,7 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.batch.core.job.JobSupport; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; import org.springframework.batch.item.ExecutionContext; @@ -66,7 +66,7 @@ public class JobStepTests { JobExecution jobExecution = jobRepository.createJobExecution("job", new JobParameters()); stepExecution = jobExecution.createStepExecution("step"); jobRepository.add(stepExecution); - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.afterPropertiesSet(); step.setJobLauncher(jobLauncher); diff --git a/spring-batch-core/src/test/resources/applicationContext-test2.xml b/spring-batch-core/src/test/resources/applicationContext-test2.xml index db8e78aa3..7167d0506 100644 --- a/spring-batch-core/src/test/resources/applicationContext-test2.xml +++ b/spring-batch-core/src/test/resources/applicationContext-test2.xml @@ -46,7 +46,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/JobRegistryIntegrationTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/JobRegistryIntegrationTests-context.xml index 27e850d3a..570f21a4b 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/JobRegistryIntegrationTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/JobRegistryIntegrationTests-context.xml @@ -34,7 +34,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobStepParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobStepParserTests-context.xml index 53b3ff8a4..aba01b79c 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobStepParserTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobStepParserTests-context.xml @@ -32,7 +32,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/JobLauncherIntegrationTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/JobLauncherIntegrationTests-context.xml index cabf05327..da6490d2a 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/JobLauncherIntegrationTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/JobLauncherIntegrationTests-context.xml @@ -12,7 +12,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/partition/launch-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/partition/launch-context.xml index 390be7d28..2fdbc767e 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/partition/launch-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/partition/launch-context.xml @@ -67,7 +67,7 @@ + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher"> - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/TablePrefixTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/TablePrefixTests-context.xml index 37b95908f..068dbd146 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/TablePrefixTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/TablePrefixTests-context.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/resource/ListPreparedStatementSetterTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/resource/ListPreparedStatementSetterTests-context.xml index 6ab3e35b5..3c6aee9ac 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/resource/ListPreparedStatementSetterTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/resource/ListPreparedStatementSetterTests-context.xml @@ -17,7 +17,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/context/CommitIntervalJobParameter-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/context/CommitIntervalJobParameter-context.xml index 03767268b..6627619b6 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/context/CommitIntervalJobParameter-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/context/CommitIntervalJobParameter-context.xml @@ -19,7 +19,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartInPriorStepTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartInPriorStepTests-context.xml index 2b187868e..bc867a58f 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartInPriorStepTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartInPriorStepTests-context.xml @@ -87,7 +87,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartLoopTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartLoopTests-context.xml index 4b7766cb8..fc538a3ea 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartLoopTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/RestartLoopTests-context.xml @@ -36,7 +36,7 @@ - + \ No newline at end of file diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests-context.xml index 94c1b48bf..2b74dd6fe 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests-context.xml @@ -141,7 +141,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/ScriptItemProcessorTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/ScriptItemProcessorTests-context.xml index ab7a8a912..d21ca0cd8 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/ScriptItemProcessorTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/item/ScriptItemProcessorTests-context.xml @@ -32,7 +32,7 @@ - diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/skip/ReprocessExceptionTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/skip/ReprocessExceptionTests-context.xml index b07fe5da4..bcdc56d01 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/step/skip/ReprocessExceptionTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/step/skip/ReprocessExceptionTests-context.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> - + diff --git a/spring-batch-core/src/test/resources/simple-job-launcher-context.xml b/spring-batch-core/src/test/resources/simple-job-launcher-context.xml index 8ddb088ee..b889f0872 100644 --- a/spring-batch-core/src/test/resources/simple-job-launcher-context.xml +++ b/spring-batch-core/src/test/resources/simple-job-launcher-context.xml @@ -7,7 +7,7 @@ + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher"> diff --git a/spring-batch-docs/src/main/asciidoc/job.adoc b/spring-batch-docs/src/main/asciidoc/job.adoc index 293333225..d0df6f64a 100644 --- a/spring-batch-docs/src/main/asciidoc/job.adoc +++ b/spring-batch-docs/src/main/asciidoc/job.adoc @@ -810,25 +810,25 @@ on and wire one up manually in the normal Spring way. When you use `@EnableBatchProcessing`, a `JobRegistry` is provided for you. This section describes how to configure your own. -The most basic implementation of the `JobLauncher` interface is the `SimpleJobLauncher`. +The most basic implementation of the `JobLauncher` interface is the `TaskExecutorJobLauncher`. Its only required dependency is a `JobRepository` (needed to obtain an execution). [role="xmlContent"] -The following example shows a `SimpleJobLauncher` in XML: +The following example shows a `TaskExecutorJobLauncher` in XML: .XML Configuration ==== [source, xml, role="xmlContent"] ---- + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher"> ---- ==== [role="javaContent"] -The following example shows a `SimpleJobLauncher` in Java: +The following example shows a `TaskExecutorJobLauncher` in Java: .Java Configuration ==== @@ -838,7 +838,7 @@ The following example shows a `SimpleJobLauncher` in Java: // This would reside in your BatchConfigurer implementation @Override protected JobLauncher createJobLauncher() throws Exception { - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.afterPropertiesSet(); return jobLauncher; @@ -856,7 +856,7 @@ image::{batch-asciidoc}images/job-launcher-sequence-sync.png[Job Launcher Sequen The sequence is straightforward and works well when launched from a scheduler. However, issues arise when trying to launch from an HTTP request. In this scenario, the launching -needs to be done asynchronously so that the `SimpleJobLauncher` returns immediately to its +needs to be done asynchronously so that the `TaskExecutorJobLauncher` returns immediately to its caller. This is because it is not good practice to keep an HTTP request open for the amount of time needed by long running processes (such as batch jobs). The following image shows an example sequence: @@ -864,18 +864,18 @@ an example sequence: .Asynchronous Job Launcher Sequence image::{batch-asciidoc}images/job-launcher-sequence-async.png[Async Job Launcher Sequence, scaledwidth="60%"] -You can configure the `SimpleJobLauncher` to allow for this scenario by configuring a +You can configure the `TaskExecutorJobLauncher` to allow for this scenario by configuring a `TaskExecutor`. [role="xmlContent"] -The following XML example configures a `SimpleJobLauncher` to return immediately: +The following XML example configures a `TaskExecutorJobLauncher` to return immediately: .XML Configuration ==== [source, xml, role="xmlContent"] ---- + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher"> @@ -885,7 +885,7 @@ The following XML example configures a `SimpleJobLauncher` to return immediately ==== [role="javaContent"] -The following Java example configures a `SimpleJobLauncher` to return immediately: +The following Java example configures a `TaskExecutorJobLauncher` to return immediately: .Java Configuration ==== @@ -893,7 +893,7 @@ The following Java example configures a `SimpleJobLauncher` to return immediatel ---- @Bean public JobLauncher jobLauncher() { - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(jobRepository()); jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor()); jobLauncher.afterPropertiesSet(); @@ -1034,7 +1034,7 @@ The following example shows a sample configuration for `endOfDay` in XML: + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher" /> ---- ==== @@ -1105,7 +1105,7 @@ The following example shows a sample configuration for `endOfDay` in XML: + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher" /> ---- ==== diff --git a/spring-batch-docs/src/main/asciidoc/spring-batch-integration.adoc b/spring-batch-docs/src/main/asciidoc/spring-batch-integration.adoc index cd4f41816..946475354 100644 --- a/spring-batch-docs/src/main/asciidoc/spring-batch-integration.adoc +++ b/spring-batch-docs/src/main/asciidoc/spring-batch-integration.adoc @@ -275,10 +275,10 @@ public FileMessageToJobRequest fileMessageToJobRequest() { @Bean public JobLaunchingGateway jobLaunchingGateway() { - SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher(); - simpleJobLauncher.setJobRepository(jobRepository); - simpleJobLauncher.setTaskExecutor(new SyncTaskExecutor()); - JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(simpleJobLauncher); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); + jobLauncher.setJobRepository(jobRepository); + jobLauncher.setTaskExecutor(new SyncTaskExecutor()); + JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(jobLauncher); return jobLaunchingGateway; } diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml index 83885bac4..82254080a 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml @@ -89,7 +89,7 @@ - + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests-context.xml index 8464b96e9..897746e49 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests-context.xml @@ -128,7 +128,7 @@ - + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml index 2472da975..609aa66ee 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml @@ -118,7 +118,7 @@ - + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests-context.xml index 29d7f10a8..79d1ce37f 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests-context.xml @@ -78,7 +78,7 @@ - + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTests-context.xml index 64b114663..c389d4ce5 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTests-context.xml @@ -14,7 +14,7 @@ - + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTestsRunning-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTestsRunning-context.xml index 7dc6b4d53..44d4170f9 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTestsRunning-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParserTestsRunning-context.xml @@ -14,7 +14,7 @@ - + diff --git a/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml b/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml index d18c02c4b..d6e9ee27d 100644 --- a/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml +++ b/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml @@ -4,7 +4,7 @@ xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> - + diff --git a/spring-batch-samples/README.md b/spring-batch-samples/README.md index 5c24aee13..90b851f94 100644 --- a/spring-batch-samples/README.md +++ b/spring-batch-samples/README.md @@ -693,7 +693,7 @@ bean is different from the other samples only in that it uses an asynchronous task executor, so that the jobs are launched in a separate thread to the main method: - + diff --git a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml index 53ad9ab96..560d3f1c7 100644 --- a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml @@ -6,7 +6,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml index d6fc99a56..bbf14928f 100644 --- a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml @@ -7,7 +7,7 @@ + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher"> diff --git a/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml b/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml index 39307ffcb..0840a9262 100644 --- a/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-batch-test/src/test/resources/simple-job-launcher-context.xml b/spring-batch-test/src/test/resources/simple-job-launcher-context.xml index 09fa67a15..237e3aadd 100755 --- a/spring-batch-test/src/test/resources/simple-job-launcher-context.xml +++ b/spring-batch-test/src/test/resources/simple-job-launcher-context.xml @@ -10,7 +10,7 @@ + class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher">