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

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

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

origin: spring-projects/spring-batch

/**
 * Build a step that executes the flow provided, normally composed of other steps. The flow is not executed in a
 * transaction because the individual steps are supposed to manage their own transaction state.
 * 
 * @return a flow step
 */
public Step build() {
  FlowStep step = new FlowStep();
  step.setName(getName());
  step.setFlow(flow);
  super.enhance(step);
  try {
    step.afterPropertiesSet();
  }
  catch (Exception e) {
    throw new StepBuilderException(e);
  }
  return step;
}
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: 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

/**
 * Test method for {@link org.springframework.batch.core.job.flow.FlowStep#afterPropertiesSet()}.
 */
@Test(expected=IllegalStateException.class)
public void testAfterPropertiesSet() throws Exception{
  FlowStep step = new FlowStep();
  step.setJobRepository(jobRepository);
  step.afterPropertiesSet();
}
origin: spring-projects/spring-batch

/**
 * Test method for {@link org.springframework.batch.core.job.flow.FlowStep#doExecute(org.springframework.batch.core.StepExecution)}.
 */
@Test
public void testExecuteWithParentContext() throws Exception {
  FlowStep step = new FlowStep();
  step.setJobRepository(jobRepository);
  SimpleFlow flow = new SimpleFlow("job");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end0"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end0")));
  flow.setStateTransitions(transitions);
  step.setFlow(flow);
  step.afterPropertiesSet();
  StepExecution stepExecution = jobExecution.createStepExecution("step");
  stepExecution.getExecutionContext().put("foo", "bar");
  jobRepository.add(stepExecution);
  step.execute(stepExecution);
  stepExecution = getStepExecution(jobExecution, "step");
  assertEquals(ExitStatus.COMPLETED, stepExecution.getExitStatus());
  stepExecution = getStepExecution(jobExecution, "step1");
  assertEquals(ExitStatus.COMPLETED, stepExecution.getExitStatus());
  assertEquals("bar", stepExecution.getExecutionContext().get("foo"));
}
origin: org.springframework.batch/org.springframework.batch.core

@SuppressWarnings("serial")
private void configureFlowStep(FlowStep ts) {
  configureAbstractStep(ts);
  if (flow != null) {
    ts.setFlow(flow);
  }
}
origin: org.springframework.batch/org.springframework.batch.core

FlowStep ts = new FlowStep();
configureFlowStep(ts);
return ts;
origin: spring-projects/spring-batch

/**
 * Test method for {@link org.springframework.batch.core.job.flow.FlowStep#doExecute(org.springframework.batch.core.StepExecution)}.
 */
@Test
public void testDoExecute() throws Exception {
  FlowStep step = new FlowStep();
  step.setJobRepository(jobRepository);
  SimpleFlow flow = new SimpleFlow("job");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "step2"));
  StepState step2 = new StepState(new StubStep("step2"));
  transitions.add(StateTransition.createStateTransition(step2, ExitStatus.FAILED.getExitCode(), "end0"));
  transitions.add(StateTransition.createStateTransition(step2, ExitStatus.COMPLETED.getExitCode(), "end1"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.FAILED, "end0")));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end1")));
  flow.setStateTransitions(transitions);
  step.setFlow(flow);
  step.afterPropertiesSet();
  StepExecution stepExecution = jobExecution.createStepExecution("step");
  jobRepository.add(stepExecution);
  step.execute(stepExecution);
  stepExecution = getStepExecution(jobExecution, "step");
  assertEquals(ExitStatus.COMPLETED, stepExecution.getExitStatus());
  stepExecution = getStepExecution(jobExecution, "step2");
  assertEquals(ExitStatus.COMPLETED, stepExecution.getExitStatus());
  assertEquals(3, jobExecution.getStepExecutions().size());
}
origin: org.springframework.batch/spring-batch-core

/**
 * Build a step that executes the flow provided, normally composed of other steps. The flow is not executed in a
 * transaction because the individual steps are supposed to manage their own transaction state.
 * 
 * @return a flow step
 */
public Step build() {
  FlowStep step = new FlowStep();
  step.setName(getName());
  step.setFlow(flow);
  super.enhance(step);
  try {
    step.afterPropertiesSet();
  }
  catch (Exception e) {
    throw new StepBuilderException(e);
  }
  return step;
}
origin: spring-projects/spring-batch

@Test
public void testDoExecuteAndFail() throws Exception {
  FlowStep step = new FlowStep();
  step.setJobRepository(jobRepository);
  SimpleFlow flow = new SimpleFlow("job");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "step2"));
  StepState step2 = new StepState(new StubStep("step2", true));
  transitions.add(StateTransition.createStateTransition(step2, ExitStatus.FAILED.getExitCode(), "end0"));
  transitions.add(StateTransition.createStateTransition(step2, ExitStatus.COMPLETED.getExitCode(), "end1"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.FAILED, "end0")));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end1")));
  flow.setStateTransitions(transitions);
  step.setFlow(flow);
  step.afterPropertiesSet();
  StepExecution stepExecution = jobExecution.createStepExecution("step");
  jobRepository.add(stepExecution);
  step.execute(stepExecution);
  stepExecution = getStepExecution(jobExecution, "step1");
  assertEquals(ExitStatus.COMPLETED, stepExecution.getExitStatus());
  stepExecution = getStepExecution(jobExecution, "step2");
  assertEquals(ExitStatus.FAILED, stepExecution.getExitStatus());
  stepExecution = getStepExecution(jobExecution, "step");
  assertEquals(ExitStatus.FAILED, stepExecution.getExitStatus());
  assertEquals(3, jobExecution.getStepExecutions().size());
}
origin: org.springframework.batch/spring-batch-core

/**
 * 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: apache/servicemix-bundles

/**
 * 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: apache/servicemix-bundles

/**
 * Build a step that executes the flow provided, normally composed of other steps. The flow is not executed in a
 * transaction because the individual steps are supposed to manage their own transaction state.
 * 
 * @return a flow step
 */
public Step build() {
  FlowStep step = new FlowStep();
  step.setName(getName());
  step.setFlow(flow);
  super.enhance(step);
  try {
    step.afterPropertiesSet();
  }
  catch (Exception e) {
    throw new StepBuilderException(e);
  }
  return step;
}
origin: apache/servicemix-bundles

/**
 * 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: org.springframework.batch/spring-batch-core

/**
 * 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.core/org.motechproject.org.springframework.batch.core

/**
 * Build a step that executes the flow provided, normally composed of other steps. The flow is not executed in a
 * transaction because the individual steps are supposed to manage their own transaction state.
 * 
 * @return a flow step
 */
public Step build() {
  FlowStep step = new FlowStep();
  step.setName(getName());
  step.setFlow(flow);
  super.enhance(step);
  try {
    step.afterPropertiesSet();
  }
  catch (Exception e) {
    throw new StepBuilderException(e);
  }
  return step;
}
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

/**
 * 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: org.springframework.batch/org.springframework.batch.core

/**
 * Delegate to the flow provided for the execution of the step.
 * 
 * @see AbstractStep#doExecute(StepExecution)
 */
@Override
protected void doExecute(StepExecution stepExecution) throws Exception {
  try {
    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.core/org.motechproject.org.springframework.batch.core

/**
 * Delegate to the flow provided for the execution of the step.
 * 
 * @see AbstractStep#doExecute(StepExecution)
 */
@Override
protected void doExecute(StepExecution stepExecution) throws Exception {
  try {
    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);
  }
}
org.springframework.batch.core.job.flowFlowStep

Javadoc

A Step implementation that delegates to a Flow. Useful for logical grouping of steps, and especially for partitioning with multiple steps per execution. If the flow has steps then when the FlowStepexecutes, all steps including the parent FlowStep will have executions in the JobRepository (one for the parent and one each for the flow steps).

Most used methods

  • <init>
    Constructor for a FlowStep that sets the flow and of the step explicitly.
  • setFlow
    Public setter for the flow.
  • afterPropertiesSet
    Ensure that the flow is set.
  • getJobRepository
  • getName
  • setName
  • execute
  • setJobRepository

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • findViewById (Activity)
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • BoxLayout (javax.swing)
  • JFileChooser (javax.swing)
  • JFrame (javax.swing)
  • CodeWhisperer alternatives
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