Package org.springframework.batch.core
Class ExitStatus
java.lang.Object
org.springframework.batch.core.ExitStatus
- All Implemented Interfaces:
Serializable
,Comparable<ExitStatus>
Value object used to carry information about the status of a
job or step execution.
ExitStatus
is immutable and, therefore, thread-safe.- Author:
- Dave Syer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ExitStatus
Convenient constant value representing finished processing.static final ExitStatus
Convenient constant value representing continuable state where processing is still taking place, so no further action is required.static final ExitStatus
Convenient constant value representing finished processing with an error.static final ExitStatus
Convenient constant value representing a job that did no processing (for example, because it was already complete).static final ExitStatus
Convenient constant value representing finished processing with interrupted status.static final ExitStatus
Convenient constant value representing unknown state - assumed to not be continuable. -
Constructor Summary
ConstructorsConstructorDescriptionExitStatus
(String exitCode) Constructor that accepts the exit code and sets the exit description to an emptyString
.ExitStatus
(String exitCode, String exitDescription) Constructor that establishes the exit code and the exit description for theExitStatus
. -
Method Summary
Modifier and TypeMethodDescriptionaddExitDescription
(String description) Add an exit description to an existingExitStatus
.addExitDescription
(Throwable throwable) Extract the stack trace from the throwable provided and append it to the existing description.and
(ExitStatus status) Create a newExitStatus
with a logical combination of the exit code and a concatenation of the descriptions.int
compareTo
(ExitStatus status) boolean
Compare the fields, one by one.Getter for the exit code (defaults to blank).Getter for the exit description (defaults to blank)int
hashCode()
Compatible with the equals implementation.static boolean
isNonDefaultExitStatus
(ExitStatus status) boolean
Check if this status represents a running process.replaceExitCode
(String code) Add an exit code to an existingExitStatus
.toString()
-
Field Details
-
UNKNOWN
Convenient constant value representing unknown state - assumed to not be continuable. -
EXECUTING
Convenient constant value representing continuable state where processing is still taking place, so no further action is required. Used for asynchronous execution scenarios where the processing is happening in another thread or process and the caller is not required to wait for the result. -
COMPLETED
Convenient constant value representing finished processing. -
NOOP
Convenient constant value representing a job that did no processing (for example, because it was already complete). -
FAILED
Convenient constant value representing finished processing with an error. -
STOPPED
Convenient constant value representing finished processing with interrupted status.
-
-
Constructor Details
-
ExitStatus
Constructor that accepts the exit code and sets the exit description to an emptyString
.- Parameters:
exitCode
- The exit code to be used for theExitStatus
.
-
ExitStatus
Constructor that establishes the exit code and the exit description for theExitStatus
.- Parameters:
exitCode
- The exit code to be used for theExitStatus
.exitDescription
- The exit description to be used for theExitStatus
.
-
-
Method Details
-
getExitCode
Getter for the exit code (defaults to blank).- Returns:
- the exit code.
-
getExitDescription
Getter for the exit description (defaults to blank)- Returns:
String
containing the exit description.
-
and
Create a newExitStatus
with a logical combination of the exit code and a concatenation of the descriptions. If either value has a higher severity, its exit code is used in the result. In the case of equal severity, the exit code is replaced if the new value is alphabetically greater.
Severity is defined by the exit code:- Codes beginning with EXECUTING have severity 1
- Codes beginning with COMPLETED have severity 2
- Codes beginning with NOOP have severity 3
- Codes beginning with STOPPED have severity 4
- Codes beginning with FAILED have severity 5
- Codes beginning with UNKNOWN have severity 6
If the input isnull
just return this.- Parameters:
status
- AnExitStatus
object to combine with this one.- Returns:
- a new
ExitStatus
combining the current value and the argument provided.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ExitStatus>
- Parameters:
status
- AnExitStatus
to compare- Returns:
- greater than zero, 0, or less than zero, according to the severity and exit code.
- See Also:
-
toString
-
equals
Compare the fields, one by one. -
hashCode
public int hashCode()Compatible with the equals implementation. -
replaceExitCode
Add an exit code to an existingExitStatus
. If there is already a code present, it will be replaced.- Parameters:
code
- The code to add.- Returns:
- a new
ExitStatus
with the same properties but a new exit code.
-
isRunning
public boolean isRunning()Check if this status represents a running process.- Returns:
true
if the exit code isEXECUTING
orUNKNOWN
.
-
addExitDescription
Add an exit description to an existingExitStatus
. If there is already a description present, the two are concatenated with a semicolon.- Parameters:
description
- The description to add.- Returns:
- a new
ExitStatus
with the same properties but a new exit description.
-
addExitDescription
Extract the stack trace from the throwable provided and append it to the existing description.- Parameters:
throwable
- AThrowable
instance containing the stack trace.- Returns:
- a new ExitStatus with the stack trace appended.
-
isNonDefaultExitStatus
- Parameters:
status
- TheExitStatus
object containing the exit code to be evaluated.- Returns:
true
if the value matches a known exit code.
-