Tabnine Logo
Flow
Code IndexAdd Tabnine to your IDE (free)

How to use
Flow
in
org.springframework.batch.core.job.flow

Best Java code snippets using org.springframework.batch.core.job.flow.Flow (Showing top 20 results out of 315)

origin: spring-projects/spring-batch

  @Override
  public FlowExecution call() throws Exception {
    return flow.start(executor);
  }
});
origin: spring-projects/spring-batch

/**
 * Constructor for a {@link FlowStep} that sets the flow and of the step
 * explicitly.
 *
 * @param flow the {@link Flow} instance to be associated with this step.
 */
public FlowStep(Flow flow) {
  super(flow.getName());
}
origin: spring-projects/spring-batch

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;
    }
  }
}
origin: spring-projects/spring-batch

@Override
public FlowExecutionStatus handle(FlowExecutor executor) throws Exception {
  return flow.start(executor).getStatus();
}
origin: spring-projects/spring-batch

/**
 * Ensure that the flow is set.
 * @see AbstractStep#afterPropertiesSet()
 */
@Override
public void afterPropertiesSet() throws Exception {
  Assert.state(flow != null, "A Flow must be provided");
  if (getName()==null) {
    setName(flow.getName());
  }
  super.afterPropertiesSet();
}
origin: spring-projects/spring-batch

/**
 * @param flow
 * @param map
 */
private void findSteps(Flow flow, Map<String, Step> map) {
  for (State state : flow.getStates()) {
    if (state instanceof StepLocator) {
      StepLocator locator = (StepLocator) state;
      for (String name : locator.getStepNames()) {
        map.put(name, locator.getStep(name));
      }
    } else if (state instanceof StepHolder) {
      Step step = ((StepHolder) state).getStep();
      String name = step.getName();
      stepMap.put(name, step);
    }
    else if (state instanceof FlowHolder) {
      for (Flow subflow : ((FlowHolder) state).getFlows()) {
        findSteps(subflow, map);
      }
    }
  }
}
origin: spring-projects/spring-batch

@Test
public void testBasicHandling() throws Exception {
  Collection<Flow> flows  = new ArrayList<>();
  Flow flow1 = mock(Flow.class);
  Flow flow2 = mock(Flow.class);
  flows.add(flow1);
  flows.add(flow2);
  SplitState state = new SplitState(flows, "foo");
  when(flow1.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));
  when(flow2.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));
  FlowExecutionStatus result = state.handle(executor);
  assertEquals(FlowExecutionStatus.COMPLETED, result);
}
origin: spring-projects/spring-batch

private State createState(Object input) {
  State result;
  if (input instanceof Step) {
    if (!states.containsKey(input)) {
      Step step = (Step) input;
      states.put(input, new StepState(prefix + step.getName(), step));
    }
    result = states.get(input);
  }
  else if (input instanceof JobExecutionDecider) {
    if (!states.containsKey(input)) {
      states.put(input, new DecisionState((JobExecutionDecider) input, prefix + "decision"
          + (decisionCounter++)));
    }
    result = states.get(input);
  }
  else if (input instanceof Flow) {
    if (!states.containsKey(input)) {
      states.put(input, new FlowState((Flow) input, prefix + ((Flow) input).getName()));
    }
    result = states.get(input);
  }
  else {
    throw new FlowBuilderException("No state can be created for: " + input);
  }
  dirty = true;
  return result;
}
origin: org.springframework.batch/spring-batch-core

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;
    }
  }
}
origin: spring-projects/spring-batch

@Test
public void testConcurrentHandling() throws Exception {
  Flow flow1 = mock(Flow.class);
  Flow flow2 = mock(Flow.class);
  SplitState state = new SplitState(Arrays.asList(flow1, flow2), "foo");
  state.setTaskExecutor(new SimpleAsyncTaskExecutor());
  when(flow1.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));
  when(flow2.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));
  FlowExecutionStatus result = state.handle(executor);
  assertEquals(FlowExecutionStatus.COMPLETED, result);
}
origin: spring-projects/spring-batch

throw new FlowExecutionException("TaskExecutor rejected task for flow=" + flow.getName());
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

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;
    }
  }
}
origin: spring-projects/spring-batch

/**
 * @see AbstractJob#doExecute(JobExecution)
 */
@Override
protected void doExecute(final JobExecution execution) throws JobExecutionException {
  try {
    JobFlowExecutor executor = new JobFlowExecutor(getJobRepository(),
        new SimpleStepHandler(getJobRepository()), execution);
    executor.updateJobExecutionStatus(flow.start(executor).getStatus());
  }
  catch (FlowExecutionException e) {
    if (e.getCause() instanceof JobExecutionException) {
      throw (JobExecutionException) e.getCause();
    }
    throw new JobExecutionException("Flow execution ended unexpectedly", e);
  }
}
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

/**
 * Constructor for a {@link FlowStep} that sets the flow and of the step
 * explicitly.
 */
public FlowStep(Flow flow) {
  super(flow.getName());
}
origin: apache/servicemix-bundles

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;
    }
  }
}
origin: spring-projects/spring-batch

/**
 * Delegate to the flow provided for the execution of the step.
 * 
 * @see AbstractStep#doExecute(StepExecution)
 */
@Override
protected void doExecute(StepExecution stepExecution) throws Exception {
  try {
    stepExecution.getExecutionContext().put(STEP_TYPE_KEY, this.getClass().getName());
    StepHandler stepHandler = new SimpleStepHandler(getJobRepository(), stepExecution.getExecutionContext());
    FlowExecutor executor = new JobFlowExecutor(getJobRepository(), stepHandler, stepExecution.getJobExecution());
    executor.updateJobExecutionStatus(flow.start(executor).getStatus());
    stepExecution.upgradeStatus(executor.getJobExecution().getStatus());
    stepExecution.setExitStatus(executor.getJobExecution().getExitStatus());
  }
  catch (FlowExecutionException e) {
    if (e.getCause() instanceof JobExecutionException) {
      throw (JobExecutionException) e.getCause();
    }
    throw new JobExecutionException("Flow execution ended unexpectedly", e);
  }
}
origin: org.springframework.batch/spring-batch-core

/**
 * Constructor for a {@link FlowStep} that sets the flow and of the step
 * explicitly.
 *
 * @param flow the {@link Flow} instance to be associated with this step.
 */
public FlowStep(Flow flow) {
  super(flow.getName());
}
origin: org.springframework.batch/spring-batch-core

/**
 * @param flow
 * @param map
 */
private void findSteps(Flow flow, Map<String, Step> map) {
  for (State state : flow.getStates()) {
    if (state instanceof StepLocator) {
      StepLocator locator = (StepLocator) state;
      for (String name : locator.getStepNames()) {
        map.put(name, locator.getStep(name));
      }
    } else if (state instanceof StepHolder) {
      Step step = ((StepHolder) state).getStep();
      String name = step.getName();
      stepMap.put(name, step);
    }
    else if (state instanceof FlowHolder) {
      for (Flow subflow : ((FlowHolder) state).getFlows()) {
        findSteps(subflow, map);
      }
    }
  }
}
origin: spring-projects/spring-batch

/**
 * @see AbstractJob#doExecute(JobExecution)
 */
@Override
protected void doExecute(final JobExecution execution) throws JobExecutionException {
  try {
    JobFlowExecutor executor = new JsrFlowExecutor(getJobRepository(),
        new JsrStepHandler(getJobRepository(), jobExplorer), execution);
    State startState = ((JsrFlow)flow).getStartState();
    validateFirstStep(startState);
    executor.updateJobExecutionStatus(flow.start(executor).getStatus());
  }
  catch (FlowExecutionException e) {
    if (e.getCause() instanceof JobExecutionException) {
      throw (JobExecutionException) e.getCause();
    }
    throw new JobExecutionException("Flow execution ended unexpectedly", e);
  }
}
origin: apache/servicemix-bundles

/**
 * Constructor for a {@link FlowStep} that sets the flow and of the step
 * explicitly.
 *
 * @param flow the {@link Flow} instance to be associated with this step.
 */
public FlowStep(Flow flow) {
  super(flow.getName());
}
org.springframework.batch.core.job.flowFlow

Most used methods

  • start
  • getName
  • getStates
    Convenient accessor for clients needing to explore the states of this flow.

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now