Add support to use any type as a job parameter

This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* https://github.com/spring-projects/spring-batch/issues/3960
* https://github.com/spring-projects/spring-batch/issues/2122
* https://github.com/spring-projects/spring-batch/issues/1035
* https://github.com/spring-projects/spring-batch/issues/1983
This commit is contained in:
Mahmoud Ben Hassine
2022-09-30 10:31:22 +02:00
parent 027302469a
commit 2660f2bb27
72 changed files with 2508 additions and 927 deletions

View File

@@ -153,8 +153,8 @@ public class JobLauncherTestUtils {
* of type {@code long}, to ensure that the job instance will be unique.
*/
public JobParameters getUniqueJobParameters() {
Map<String, JobParameter> parameters = new HashMap<>();
parameters.put("random", new JobParameter(this.secureRandom.nextLong()));
Map<String, JobParameter<?>> parameters = new HashMap<>();
parameters.put("random", new JobParameter(this.secureRandom.nextLong(), Long.class));
return new JobParameters(parameters);
}

View File

@@ -63,7 +63,7 @@ public class JobRepositoryTestUtils {
@Override
public JobParameters getNext(@Nullable JobParameters parameters) {
return new JobParameters(Collections.singletonMap("count", new JobParameter(count++)));
return new JobParameters(Collections.singletonMap("count", new JobParameter(count++, Long.class)));
}
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -185,8 +185,8 @@ public class StepRunner {
* timestamp, to ensure that the job instance will be unique
*/
private JobParameters makeUniqueJobParameters() {
Map<String, JobParameter> parameters = new HashMap<>();
parameters.put("timestamp", new JobParameter(new Date().getTime()));
Map<String, JobParameter<?>> parameters = new HashMap<>();
parameters.put("timestamp", new JobParameter(new Date().getTime(), Long.class));
return new JobParameters(parameters);
}