BATCH-1065: Added check to ensure that a transition from an EndState does not have a "pattern" associated. EndState transitions must always be universal.

This commit is contained in:
dhgarrette
2009-02-13 06:37:08 +00:00
parent 73ed78da31
commit f562b01d6e
7 changed files with 13 additions and 8 deletions

View File

@@ -46,9 +46,10 @@ public interface State {
FlowExecutionStatus handle(FlowExecutor executor) throws Exception;
/**
* Validate that the nextState is appropriate for this State.
* Validate that the transition attributes are appropriate for this State.
*
* @param pattern
* @param nextState
*/
void validate(String nextState);
void validate(String pattern, String nextState);
}

View File

@@ -100,7 +100,7 @@ public class StateTransition implements Comparable<StateTransition> {
}
Assert.notNull(state, "A state is required for a StateTransition");
state.validate(next);
state.validate(pattern, next);
this.next = next;
this.state = state;

View File

@@ -44,7 +44,7 @@ public class DecisionState extends AbstractState {
/* (non-Javadoc)
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
*/
public void validate(String nextState) {
public void validate(String pattern, String nextState) {
if (nextState == null) {
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
+ "] requires a 'next' state.");

View File

@@ -83,11 +83,15 @@ public class EndState extends AbstractState {
/* (non-Javadoc)
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
*/
public void validate(String nextState) {
public void validate(String pattern, String nextState) {
if (status != BatchStatus.INCOMPLETE && nextState != null) {
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
+ "] may not have a 'next' state.");
}
if (pattern != null) {
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
+ "] may not have a 'pattern'.");
}
}
/*

View File

@@ -106,7 +106,7 @@ public class SplitState extends AbstractState {
/* (non-Javadoc)
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
*/
public void validate(String nextState) {
public void validate(String pattern, String nextState) {
if (nextState == null) {
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
+ "] requires a 'next' state.");

View File

@@ -65,7 +65,7 @@ public class StepState extends AbstractState implements StepHolder {
/* (non-Javadoc)
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
*/
public void validate(String nextState) {
public void validate(String pattern, String nextState) {
if (nextState == null) {
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
+ "] requires a 'next' state.");

View File

@@ -50,6 +50,6 @@ public class StateSupport extends AbstractState {
return this.status;
}
public void validate(String nextState) {
public void validate(String pattern, String nextState) {
}
}