@Override public String toString() { return String.format("StateTransition: [state=%s, pattern=%s, next=%s]", state == null ? null : state.getName(), pattern, next); }
private boolean stateNameEndsWithStepName(State state, StepExecution stepExecution) { return !(stepExecution == null || state == null) && !state.getName().endsWith(stepExecution.getStepName()); }
private boolean matches(String from, String status) { for (StateTransition transition : transitions) { if (from.equals(transition.getState().getName()) && transition.matches(status)) { return true; } } return false; }
private void doFrom(Object input) { if (currentState == null) { doStart(input); } State state = createState(input); tos.put(currentState.getName(), currentState); this.currentState = state; }
private void addTransition(String pattern, State next) { tos.put(next.getName(), next); transitions.add(StateTransition.createStateTransition(currentState, pattern, next.getName())); if (transitions.size() == 1) { transitions.add(StateTransition.createEndStateTransition(failedState)); transitions.add(StateTransition.createEndStateTransition(completedState)); transitions.add(StateTransition.createEndStateTransition(stoppedState)); } if (next.isEndState()) { transitions.add(StateTransition.createEndStateTransition(next)); } dirty = true; }
/** * @see Flow#start(FlowExecutor) */ @Override public FlowExecution start(FlowExecutor executor) throws FlowExecutionException { if (startState == null) { initializeTransitions(); } State state = startState; String stateName = state.getName(); return resume(stateName, executor); }
private void validateFirstStep(State startState) throws JobExecutionException { while(true) { if(startState instanceof DelegateState) { startState = ((DelegateState) startState).getState(); } else if(startState instanceof JsrStepState) { String stepName = startState.getName().substring(startState.getName().indexOf(".") + 1, startState.getName().length()); Step step = ((JsrStepState) startState).getStep(stepName); if(step instanceof DecisionStep) { throw new JobExecutionException("Decision step is an invalid first step"); } else { break; } } else if(startState instanceof FlowState){ Flow firstFlow = ((FlowState) startState).getFlows().iterator().next(); startState = firstFlow.getStates().iterator().next(); } else { break; } } }
/** * Convenience method to get a state that proxies the input but with a * different name, appropriate to this flow. If the state is a StepState * then the step name is also changed. * * @param state * @return */ private State getProxyState(State state) { String oldName = state.getName(); if (oldName.startsWith(prefix)) { return state; } String stateName = prefix + oldName; if (state instanceof StepState) { return createNewStepState(state, oldName, stateName); } return new DelegateState(stateName, state); }
protected boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution) { boolean continued = true; continued = state != null && status!=FlowExecutionStatus.STOPPED; if(stepExecution != null) { Boolean reRun = (Boolean) stepExecution.getExecutionContext().get("batch.restart"); Boolean executed = (Boolean) stepExecution.getExecutionContext().get("batch.executed"); if((executed == null || !executed) && reRun != null && reRun && status == FlowExecutionStatus.STOPPED && !state.getName().endsWith(stepExecution.getStepName()) ) { continued = true; } } return continued; }
stateName = state.getName();
@Test public void testGetStateExists() throws Exception { flow.setStateTransitions(Collections.singletonList(StateTransition.createEndStateTransition(new StubState( "step1")))); flow.afterPropertiesSet(); State state = flow.getState("step1"); assertNotNull(state); assertEquals("step1", state.getName()); }
@Override public String toString() { return String.format("StateTransition: [state=%s, pattern=%s, next=%s]", state == null ? null : state.getName(), pattern, next); }
@Override public String toString() { return String.format("StateTransition: [state=%s, pattern=%s, next=%s]", state == null ? null : state.getName(), pattern, next); }
private void doFrom(Object input) { if (currentState == null) { doStart(input); } State state = createState(input); tos.put(currentState.getName(), currentState); this.currentState = state; }
private boolean matches(String from, String status) { for (StateTransition transition : transitions) { if (from.equals(transition.getState().getName()) && transition.matches(status)) { return true; } } return false; }
/** * @see Flow#start(FlowExecutor) */ @Override public FlowExecution start(FlowExecutor executor) throws FlowExecutionException { if (startState == null) { initializeTransitions(); } State state = startState; String stateName = state.getName(); return resume(stateName, executor); }
protected boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution) { boolean continued = true; continued = state != null && status!=FlowExecutionStatus.STOPPED; if(stepExecution != null) { Boolean reRun = (Boolean) stepExecution.getExecutionContext().get("batch.restart"); Boolean executed = (Boolean) stepExecution.getExecutionContext().get("batch.executed"); if((executed == null || !executed) && reRun != null && reRun && status == FlowExecutionStatus.STOPPED && !state.getName().endsWith(stepExecution.getStepName()) ) { continued = true; } } return continued; }
protected boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution) { boolean continued = true; continued = state != null && status!=FlowExecutionStatus.STOPPED; if(stepExecution != null) { Boolean reRun = (Boolean) stepExecution.getExecutionContext().get("batch.restart"); Boolean executed = (Boolean) stepExecution.getExecutionContext().get("batch.executed"); if((executed == null || !executed) && reRun != null && reRun && status == FlowExecutionStatus.STOPPED && !state.getName().endsWith(stepExecution.getStepName()) ) { continued = true; } } return continued; }