OPEN - issue BATCH-378: RepeatListener is confusing and too generic to use for 'intercepting' a step
http://jira.springframework.org/browse/BATCH-378 Replace RepeatListener with StepListener in TaskletStep.
This commit is contained in:
@@ -17,6 +17,8 @@ package org.springframework.batch.repeat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Value object used to carry information about the status of a
|
||||
* {@link RepeatOperations}.
|
||||
@@ -41,8 +43,7 @@ public class ExitStatus implements Serializable {
|
||||
/**
|
||||
* Convenient constant value representing unfinished processing.
|
||||
*/
|
||||
public static final ExitStatus CONTINUABLE = new ExitStatus(true,
|
||||
"CONTINUABLE");
|
||||
public static final ExitStatus CONTINUABLE = new ExitStatus(true, "CONTINUABLE");
|
||||
|
||||
/**
|
||||
* Convenient constant value representing finished processing.
|
||||
@@ -74,8 +75,7 @@ public class ExitStatus implements Serializable {
|
||||
this(continuable, exitCode, "");
|
||||
}
|
||||
|
||||
public ExitStatus(boolean continuable, String exitCode,
|
||||
String exitDescription) {
|
||||
public ExitStatus(boolean continuable, String exitCode, String exitDescription) {
|
||||
super();
|
||||
this.continuable = continuable;
|
||||
this.exitCode = exitCode;
|
||||
@@ -116,14 +116,24 @@ public class ExitStatus implements Serializable {
|
||||
* Create a new {@link ExitStatus} with a logical combination of the
|
||||
* continuable flag.
|
||||
*
|
||||
* @param continuable
|
||||
* true if the caller thinks it is safe to continue.
|
||||
* @param continuable true if the caller thinks it is safe to continue.
|
||||
* @return a new {@link ExitStatus} with {@link #isContinuable()} the
|
||||
* logical and of the current value and the argument provided.
|
||||
* logical and of the current value and the argument provided.
|
||||
*/
|
||||
public ExitStatus and(boolean continuable) {
|
||||
return new ExitStatus(this.continuable && continuable, this.exitCode,
|
||||
this.exitDescription);
|
||||
return new ExitStatus(this.continuable && continuable, this.exitCode, this.exitDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link ExitStatus} with a logical combination of the
|
||||
* continuable flag, and a con.
|
||||
*
|
||||
* @param status an {@link ExitStatus} to combine with this one.
|
||||
* @return a new {@link ExitStatus} with {@link #isContinuable()} the
|
||||
* logical and of the current value and the argument provided.
|
||||
*/
|
||||
public ExitStatus and(ExitStatus status) {
|
||||
return and(status.continuable).addExitCode(status.exitCode).addExitDescription(status.exitDescription);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -132,8 +142,7 @@ public class ExitStatus implements Serializable {
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return "continuable=" + continuable + ";exitCode=" + exitCode
|
||||
+ ";exitDescription=" + exitDescription;
|
||||
return "continuable=" + continuable + ";exitCode=" + exitCode + ";exitDescription=" + exitDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,36 +167,41 @@ public class ExitStatus implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an exit code to an existing {@link ExitStatus}.
|
||||
* Add an exit code to an existing {@link ExitStatus}. If there is already
|
||||
* a code present the two will be concatenated with a semicolon.
|
||||
*
|
||||
* @param code
|
||||
* the code to add
|
||||
* @param code the code to add
|
||||
* @return a new {@link ExitStatus} with the same properties but a new exit
|
||||
* code.
|
||||
* code.
|
||||
*/
|
||||
public ExitStatus addExitCode(String code) {
|
||||
if (StringUtils.hasText(exitCode) && StringUtils.hasLength(code) && !exitCode.equals(code)) {
|
||||
code = exitCode + "; " + code;
|
||||
}
|
||||
return new ExitStatus(continuable, code, exitDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this status represents a running process.
|
||||
*
|
||||
* @return tru eif the exit code is "RUNNING" or "UNKNOWN"
|
||||
* @return true if the exit code is "RUNNING" or "UNKNOWN"
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
return "RUNNING".equals(this.exitCode)
|
||||
|| "UNKNOWN".equals(this.exitCode);
|
||||
return "RUNNING".equals(this.exitCode) || "UNKNOWN".equals(this.exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an exit description to an existing {@link ExitStatus}.
|
||||
* Add an exit description to an existing {@link ExitStatus}. If there is already
|
||||
* a description present the two will be concatenated with a semicolon.
|
||||
*
|
||||
* @param description
|
||||
* the description to add
|
||||
* @param description the description to add
|
||||
* @return a new {@link ExitStatus} with the same properties but a new exit
|
||||
* description
|
||||
* description
|
||||
*/
|
||||
public ExitStatus addExitDescription(String description) {
|
||||
if (StringUtils.hasText(exitDescription) && StringUtils.hasText(description) &&!exitDescription.equals(description)) {
|
||||
description = exitDescription + "; " + description;
|
||||
}
|
||||
return new ExitStatus(continuable, exitCode, description);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user