Deprecating the CommandLineRunnerOrder renaming it to ApplicaitonRunnerOrder
This is to reflect the foundation class of CommandLineRunner which is ApplicationRunner
This commit is contained in:
@@ -209,10 +209,10 @@ can be 1 (the default) or be based on the
|
||||
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-spring-application.html#boot-features-application-exit[specified
|
||||
`ExitCodeGenerator`])
|
||||
|
||||
This functionality uses a new `CommandLineRunner` that replaces the one provided by Spring
|
||||
This functionality uses a new `ApplicationRunner` that replaces the one provided by Spring
|
||||
Boot. By default, it is configured with the same order. However, if you want to customize
|
||||
the order in which the `CommandLineRunner` is run, you can set its order by setting the
|
||||
`spring.cloud.task.batch.commandLineRunnerOrder` property. To have your task return the
|
||||
the order in which the `ApplicationRunner` is run, you can set its order by setting the
|
||||
`spring.cloud.task.batch.applicationRunnerOrder` property. To have your task return the
|
||||
exit code based on the result of the batch job execution, you need to write your own
|
||||
`CommandLineRunner`.
|
||||
//TODO Great place for a example showing how a custom CommandLineRunner
|
||||
|
||||
@@ -38,12 +38,12 @@ public class TaskBatchProperties {
|
||||
private String jobNames = "";
|
||||
|
||||
/**
|
||||
* The order for the {@code CommandLineRunner} used to run batch jobs when
|
||||
* The order for the {@code ApplicationRunner} used to run batch jobs when
|
||||
* {@code spring.cloud.task.batch.fail-on-job-failure=true}. Defaults to 0 (same as
|
||||
* the
|
||||
* {@link org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner}).
|
||||
* {@link org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner}).
|
||||
*/
|
||||
private int commandLineRunnerOrder = 0;
|
||||
private int applicationRunnerOrder = 0;
|
||||
|
||||
/**
|
||||
* Fixed delay in milliseconds that Spring Cloud Task will wait when checking if
|
||||
@@ -60,12 +60,22 @@ public class TaskBatchProperties {
|
||||
this.jobNames = jobNames;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getCommandLineRunnerOrder() {
|
||||
return this.commandLineRunnerOrder;
|
||||
return this.applicationRunnerOrder;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setCommandLineRunnerOrder(int commandLineRunnerOrder) {
|
||||
this.commandLineRunnerOrder = commandLineRunnerOrder;
|
||||
this.applicationRunnerOrder = commandLineRunnerOrder;
|
||||
}
|
||||
|
||||
public int getApplicationRunnerOrder() {
|
||||
return this.applicationRunnerOrder;
|
||||
}
|
||||
|
||||
public void setApplicationRunnerOrder(int applicationRunnerOrder) {
|
||||
this.applicationRunnerOrder = applicationRunnerOrder;
|
||||
}
|
||||
|
||||
public long getFailOnJobFailurePollInterval() {
|
||||
|
||||
@@ -72,7 +72,7 @@ public class TaskJobLauncherApplicationRunnerFactoryBean implements FactoryBean<
|
||||
else {
|
||||
this.jobName = taskBatchProperties.getJobNames();
|
||||
}
|
||||
this.order = taskBatchProperties.getCommandLineRunnerOrder();
|
||||
this.order = taskBatchProperties.getApplicationRunnerOrder();
|
||||
this.jobRepository = jobRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TaskJobLauncherAutoConfigurationTests {
|
||||
@Test
|
||||
public void testAutoBuiltDataSourceWithTaskJobLauncherCLROrder() {
|
||||
this.contextRunner.withPropertyValues("spring.cloud.task.batch.fail-on-job-failure=true",
|
||||
"spring.cloud.task.batch.commandLineRunnerOrder=100").run(context -> {
|
||||
"spring.cloud.task.batch.applicationRunnerOrder=100").run(context -> {
|
||||
assertThat(context.getBean(TaskJobLauncherApplicationRunner.class).getOrder()).isEqualTo(100);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user