File tree Expand file tree Collapse file tree 5 files changed +46
-7
lines changed
spring-batch-core/src/main/java/org/springframework/batch/core Expand file tree Collapse file tree 5 files changed +46
-7
lines changed Original file line number Diff line number Diff line change 31
31
public class JobBuilder extends JobBuilderHelper <JobBuilder > {
32
32
33
33
/**
34
- * Create a new builder for a job with the given name.
34
+ * Create a new builder for a job with the given job repository. The name of the job
35
+ * will be set to the bean name by default.
36
+ * @param jobRepository the job repository to which the job should report to.
37
+ * @since 6.0
38
+ */
39
+ public JobBuilder (JobRepository jobRepository ) {
40
+ super (jobRepository );
41
+ }
42
+
43
+ /**
44
+ * Create a new builder for a job with the given name and job repository.
35
45
* @param name the name of the job
36
46
* @param jobRepository the job repository to which the job should report to
37
47
* @since 5.0
Original file line number Diff line number Diff line change @@ -54,6 +54,16 @@ public abstract class JobBuilderHelper<B extends JobBuilderHelper<B>> {
54
54
55
55
private final CommonJobProperties properties ;
56
56
57
+ /**
58
+ * Create a new {@link JobBuilderHelper}.
59
+ * @param jobRepository the job repository
60
+ * @since 6.0
61
+ */
62
+ public JobBuilderHelper (JobRepository jobRepository ) {
63
+ this .properties = new CommonJobProperties ();
64
+ properties .jobRepository = jobRepository ;
65
+ }
66
+
57
67
/**
58
68
* Create a new {@link JobBuilderHelper}.
59
69
* @param name the job name
@@ -229,6 +239,8 @@ protected void enhance(AbstractJob job) {
229
239
230
240
public static class CommonJobProperties {
231
241
242
+ private String name ;
243
+
232
244
private Set <JobExecutionListener > jobExecutionListeners = new LinkedHashSet <>();
233
245
234
246
private boolean restartable = true ;
@@ -336,8 +348,6 @@ public void setRestartable(boolean restartable) {
336
348
this .restartable = restartable ;
337
349
}
338
350
339
- private String name ;
340
-
341
351
}
342
352
343
353
}
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2006-2024 the original author or authors.
2
+ * Copyright 2006-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -94,7 +94,6 @@ public AbstractStep() {
94
94
95
95
@ Override
96
96
public void afterPropertiesSet () throws Exception {
97
- Assert .state (name != null , "A Step must have a name" );
98
97
Assert .state (jobRepository != null , "JobRepository is mandatory" );
99
98
}
100
99
Original file line number Diff line number Diff line change 34
34
*/
35
35
public class StepBuilder extends StepBuilderHelper <StepBuilder > {
36
36
37
+ /**
38
+ * Initialize a step builder for a step with the given job repository. The name of the
39
+ * step will be set to the bean name by default.
40
+ * @param jobRepository the job repository to which the step should report to.
41
+ * @since 6.0
42
+ */
43
+ public StepBuilder (JobRepository jobRepository ) {
44
+ super (jobRepository );
45
+ }
46
+
37
47
/**
38
48
* Initialize a step builder for a step with the given name and job repository.
39
49
* @param name the name of the step
Original file line number Diff line number Diff line change @@ -53,6 +53,16 @@ public abstract class StepBuilderHelper<B extends StepBuilderHelper<B>> {
53
53
54
54
protected final CommonStepProperties properties ;
55
55
56
+ /**
57
+ * Create a new {@link StepBuilderHelper} with the given job repository.
58
+ * @param jobRepository the job repository
59
+ * @since 6.0
60
+ */
61
+ public StepBuilderHelper (JobRepository jobRepository ) {
62
+ this .properties = new CommonStepProperties ();
63
+ properties .jobRepository = jobRepository ;
64
+ }
65
+
56
66
/**
57
67
* Create a new {@link StepBuilderHelper}.
58
68
* @param name the step name
@@ -176,6 +186,8 @@ protected void enhance(AbstractStep step) {
176
186
177
187
public static class CommonStepProperties {
178
188
189
+ private String name ;
190
+
179
191
private List <StepExecutionListener > stepExecutionListeners = new ArrayList <>();
180
192
181
193
private int startLimit = Integer .MAX_VALUE ;
@@ -272,8 +284,6 @@ public void setAllowStartIfComplete(Boolean allowStartIfComplete) {
272
284
this .allowStartIfComplete = allowStartIfComplete ;
273
285
}
274
286
275
- private String name ;
276
-
277
287
}
278
288
279
289
}
You can’t perform that action at this time.
0 commit comments