Skip to content

Commit 4e35709

Browse files
cppwfsfmbenhassine
authored andcommitted
Add missing docs for batch.core and batch.core.configuration packages
Issue #4068
1 parent 61ffc55 commit 4e35709

32 files changed

+506
-46
lines changed

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/BatchStatus.java

+41-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,8 +37,47 @@ public enum BatchStatus {
3737
* steps that have finished processing, but were not successful, and where
3838
* they should be skipped on a restart (so FAILED is the wrong status).
3939
*/
40-
COMPLETED, STARTING, STARTED, STOPPING, STOPPED, FAILED, ABANDONED, UNKNOWN;
4140

41+
/**
42+
* The batch job has successfully completed its execution.
43+
*/
44+
COMPLETED,
45+
/**
46+
* Status of a batch job prior to its execution.
47+
*/
48+
STARTING,
49+
/**
50+
* Status of a batch job that is running.
51+
*/
52+
STARTED,
53+
/**
54+
* Status of batch job waiting for a step to complete before stopping the batch job.
55+
*/
56+
STOPPING,
57+
/**
58+
* Status of a batch job that has been stopped by request.
59+
*/
60+
STOPPED,
61+
/**
62+
* Status of a batch job that has failed during its execution.
63+
*/
64+
FAILED,
65+
/**
66+
* Status of a batch job that did not stop properly and can not be restarted.
67+
*/
68+
ABANDONED,
69+
/**
70+
* Status of a batch job that is in an uncertain state.
71+
*/
72+
UNKNOWN;
73+
74+
/**
75+
* Convenience method to return the higher value status of the statuses pass in to the method.
76+
*
77+
* @param status1 The first status to check.
78+
* @param status2 The second status to check.
79+
* @return The higher value status of the two statuses.
80+
*/
4281
public static BatchStatus max(BatchStatus status1, BatchStatus status2) {
4382
return status1.isGreaterThan(status2) ? status1 : status2;
4483
}

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,10 @@
2929
*/
3030
public interface ChunkListener extends StepListener {
3131

32-
static final String ROLLBACK_EXCEPTION_KEY = "sb_rollback_exception";
32+
/**
33+
* The key for retrieving the rollback exception.
34+
*/
35+
String ROLLBACK_EXCEPTION_KEY = "sb_rollback_exception";
3336

3437
/**
3538
* Callback before the chunk is executed, but inside the transaction.

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2013 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,10 +37,20 @@ public class Entity implements Serializable {
3737

3838
private volatile Integer version;
3939

40+
/**
41+
* Default constructor for {@link Entity}.
42+
*
43+
* The ID defaults to zero.
44+
*/
4045
public Entity() {
4146
super();
4247
}
4348

49+
/**
50+
* The constructor for the {@link Entity} where the ID is established.
51+
*
52+
* @param id The ID for the entity.
53+
*/
4454
public Entity(Long id) {
4555
super();
4656

@@ -50,10 +60,16 @@ public Entity(Long id) {
5060
this.id = id;
5161
}
5262

63+
/**
64+
* @return The ID associated with the {@link Entity}.
65+
*/
5366
public Long getId() {
5467
return id;
5568
}
5669

70+
/**
71+
* @param id The ID for the {@link Entity}.
72+
*/
5773
public void setId(Long id) {
5874
this.id = id;
5975
}

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,10 +74,21 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
7474

7575
private final String exitDescription;
7676

77+
/**
78+
* Constructor that accepts the exit code and sets the exit description to an empty {@link String}.
79+
*
80+
* @param exitCode The exit code to be used for the {@link ExitStatus}.
81+
*/
7782
public ExitStatus(String exitCode) {
7883
this(exitCode, "");
7984
}
8085

86+
/**
87+
* Constructor that establishes the exit code and the exit description for the {@link ExitStatus}.
88+
*
89+
* @param exitCode The exit code to be used for the {@link ExitStatus}.
90+
* @param exitDescription The exit description to be used for the {@link ExitStatus}.
91+
*/
8192
public ExitStatus(String exitCode, String exitDescription) {
8293
super();
8394
this.exitCode = exitCode;

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java

+50-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -65,6 +65,11 @@ public class JobExecution extends Entity {
6565

6666
private transient volatile List<Throwable> failureExceptions = new CopyOnWriteArrayList<>();
6767

68+
/**
69+
* Constructor that sets the state of the instance to the {@link JobExecution} parameter.
70+
*
71+
* @param original The {@link JobExecution} to be copied.
72+
*/
6873
public JobExecution(JobExecution original) {
6974
this.jobParameters = original.getJobParameters();
7075
this.jobInstance = original.getJobInstance();
@@ -98,45 +103,83 @@ public JobExecution(JobInstance job, Long id, @Nullable JobParameters jobParamet
98103
/**
99104
* Constructor for transient (unsaved) instances.
100105
*
101-
* @param job the enclosing {@link JobInstance}
102-
* @param jobParameters {@link JobParameters} instance for this JobExecution.
106+
* @param job The enclosing {@link JobInstance}.
107+
* @param jobParameters The {@link JobParameters} instance for this JobExecution.
103108
*/
104109
public JobExecution(JobInstance job, JobParameters jobParameters) {
105110
this(job, null, jobParameters);
106111
}
107112

113+
/**
114+
* Constructor that accepts the job execution ID and {@link JobParameters}.
115+
*
116+
* @param id The job execution ID.
117+
* @param jobParameters The {@link JobParameters} for the {@link JobExecution}.
118+
*/
108119
public JobExecution(Long id, JobParameters jobParameters) {
109120
this(null, id, jobParameters);
110121
}
111122

123+
/**
124+
* Constructor that accepts the job execution ID.
125+
*
126+
* @param id The job execution ID.
127+
*/
112128
public JobExecution(Long id) {
113129
this(null, id, null);
114130
}
115131

132+
/**
133+
* @return The current {@link JobParameters}.
134+
*/
116135
public JobParameters getJobParameters() {
117136
return this.jobParameters;
118137
}
119138

139+
/**
140+
* @return The current end time.
141+
*/
120142
public Date getEndTime() {
121143
return endTime;
122144
}
123145

146+
/**
147+
* Set the {@link JobInstance} used by the {@link JobExecution}.
148+
*
149+
* @param jobInstance The {@link JobInstance} used by the {@link JobExecution}.
150+
*/
124151
public void setJobInstance(JobInstance jobInstance) {
125152
this.jobInstance = jobInstance;
126153
}
127154

155+
/**
156+
* Set the end time.
157+
*
158+
* @param endTime The {@link Date} to be used for the end time.
159+
*/
128160
public void setEndTime(Date endTime) {
129161
this.endTime = endTime;
130162
}
131163

164+
/**
165+
* @return The current start time.
166+
*/
132167
public Date getStartTime() {
133168
return startTime;
134169
}
135170

171+
/**
172+
* Set the start time.
173+
*
174+
* @param startTime The {@link Date} to be used for the start time.
175+
*/
136176
public void setStartTime(Date startTime) {
137177
this.startTime = startTime;
138178
}
139179

180+
/**
181+
* @return The current {@link BatchStatus}.
182+
*/
140183
public BatchStatus getStatus() {
141184
return status;
142185
}
@@ -297,6 +340,10 @@ public void setLastUpdated(Date lastUpdated) {
297340
this.lastUpdated = lastUpdated;
298341
}
299342

343+
/**
344+
* Retrieve a list of exceptions.
345+
* @return The {@link List} of {@link Throwable} objects.
346+
*/
300347
public List<Throwable> getFailureExceptions() {
301348
return failureExceptions;
302349
}

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,6 +43,12 @@ public class JobInstance extends Entity {
4343

4444
private final String jobName;
4545

46+
/**
47+
* Constructor for {@link JobInstance}.
48+
*
49+
* @param id The instance ID.
50+
* @param jobName The name associated with the {@link JobInstance}.
51+
*/
4652
public JobInstance(Long id, String jobName) {
4753
super(id);
4854
Assert.hasLength(jobName, "A jobName is required");
@@ -61,6 +67,9 @@ public String toString() {
6167
return super.toString() + ", Job=[" + jobName + "]";
6268
}
6369

70+
/**
71+
* @return The current instance ID.
72+
*/
6473
public long getInstanceId() {
6574
return super.getId();
6675
}

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/JobInterruptedException.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,10 +33,21 @@ public class JobInterruptedException extends JobExecutionException {
3333

3434
private BatchStatus status = BatchStatus.STOPPED;
3535

36+
/**
37+
* Constructor that sets the message for the exception.
38+
*
39+
* @param msg The message for the exception.
40+
*/
3641
public JobInterruptedException(String msg) {
3742
super(msg);
3843
}
3944

45+
/**
46+
* Constructor that sets the message for the exception.
47+
*
48+
* @param msg The message for the exception.
49+
* @param status The desired {@link BatchStatus} of the surrounding execution after interruption.
50+
*/
4051
public JobInterruptedException(String msg, BatchStatus status) {
4152
super(msg);
4253
this.status = status;

Diff for: spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -125,6 +125,9 @@ public JobParameter(Double parameter) {
125125
this(parameter, true);
126126
}
127127

128+
/**
129+
* @return The identifying flag. It is set to true if the job parameter is identifying.
130+
*/
128131
public boolean isIdentifying() {
129132
return identifying;
130133
}
@@ -168,10 +171,25 @@ public int hashCode() {
168171
}
169172

170173
/**
171-
* Enumeration representing the type of a JobParameter.
174+
* Enumeration representing the type of {@link JobParameter}.
172175
*/
173176
public enum ParameterType {
174177

175-
STRING, DATE, LONG, DOUBLE;
178+
/**
179+
* String parameter type.
180+
*/
181+
STRING,
182+
/**
183+
* Date parameter type.
184+
*/
185+
DATE,
186+
/**
187+
* Long parameter type.
188+
*/
189+
LONG,
190+
/**
191+
* Double parameter type.
192+
*/
193+
DOUBLE;
176194
}
177195
}

0 commit comments

Comments
 (0)