Tabnine Logo
org.springframework.batch.core.step.tasklet
Code IndexAdd Tabnine to your IDE (free)

How to use org.springframework.batch.core.step.tasklet

Best Java code snippets using org.springframework.batch.core.step.tasklet (Showing top 20 results out of 315)

origin: spring-projects/spring-batch

/**
 * Register each of the objects as listeners.
 *
 * @param listeners an array of listener objects of known types.
 */
public void setChunkListeners(ChunkListener[] listeners) {
  for (int i = 0; i < listeners.length; i++) {
    registerChunkListener(listeners[i]);
  }
}
origin: spring-projects/spring-batch

/**
 * Public setter for the {@link Tasklet}.
 *
 * @param tasklet the {@link Tasklet} to set
 */
public void setTasklet(Tasklet tasklet) {
  this.tasklet = tasklet;
  if (tasklet instanceof StepExecutionListener) {
    registerStepExecutionListener((StepExecutionListener) tasklet);
  }
}
origin: spring-projects/spring-batch

/**
 * Register each of the streams for callbacks at the appropriate time in the
 * step. The {@link ItemReader} and {@link ItemWriter} are automatically
 * registered, but it doesn't hurt to also register them here. Injected
 * dependencies of the reader and writer are not automatically registered,
 * so if you implement {@link ItemWriter} using delegation to another object
 * which itself is a {@link ItemStream}, you need to register the delegate
 * here.
 *
 * @param streams an array of {@link ItemStream} objects.
 */
public void setStreams(ItemStream[] streams) {
  for (int i = 0; i < streams.length; i++) {
    registerStream(streams[i]);
  }
}
origin: spring-projects/spring-batch

private TaskletStep getStep(String[] strings, int commitInterval) throws Exception {
  TaskletStep step = new TaskletStep("stepName");
  // Only process one item:
  RepeatTemplate template = new RepeatTemplate();
  template.setCompletionPolicy(new SimpleCompletionPolicy(commitInterval));
  step.setTasklet(new TestingChunkOrientedTasklet<>(getReader(strings), itemWriter, template));
  step.setJobRepository(new JobRepositorySupport());
  step.setTransactionManager(transactionManager);
  return step;
}
origin: spring-projects/spring-batch

@Test
public void testNonRestartedJob() throws Exception {
  MockRestartableItemReader tasklet = new MockRestartableItemReader();
  step.setTasklet(new TestingChunkOrientedTasklet<>(tasklet, itemWriter));
  step.registerStream(tasklet);
  JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
  StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
  step.execute(stepExecution);
  assertFalse(tasklet.isRestoreFromCalled());
  assertTrue(tasklet.isGetExecutionAttributesCalled());
}
origin: spring-projects/spring-batch

private void initializeTasklet() {
  tasklet = new SystemCommandTasklet();
  tasklet.setEnvironmentParams(null); // inherit from parent process
  tasklet.setWorkingDirectory(null); // inherit from parent process
  tasklet.setSystemProcessExitCodeMapper(new SimpleSystemProcessExitCodeMapper());
  tasklet.setTimeout(5000); // long enough timeout
  tasklet.setTerminationCheckInterval(500);
  tasklet.setCommand("invalid command, change value for successful execution");
  tasklet.setInterruptOnCancel(true);
  tasklet.setTaskExecutor(new SimpleAsyncTaskExecutor());
}
origin: spring-projects/spring-batch

protected Step createStep(String stepName) {
  return new TaskletStep(stepName);
}
origin: spring-projects/spring-batch

@Test
public void testDifferentParametersOrder() throws Exception {
  adapter.setTargetMethod("execute2");
  RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext);
  assertEquals(RepeatStatus.FINISHED, repeatStatus);
  assertEquals(tasklet.getStepContribution(), stepContribution);
  assertEquals(tasklet.getChunkContext(), chunkContext);
}
origin: spring-projects/spring-batch

@Test
public void testArgumentSubsetWithOnlyChunkContext() throws Exception {
  adapter.setTargetMethod("execute3");
  RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext);
  assertEquals(RepeatStatus.FINISHED, repeatStatus);
  assertEquals(tasklet.getChunkContext(), chunkContext);
}
origin: spring-projects/spring-batch

@Test
public void testArgumentSubsetWithOnlyStepContributionAndCompatibleReturnTypeBoolean() throws Exception {
  adapter.setTargetMethod("execute8");
  RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext);
  assertEquals(RepeatStatus.FINISHED, repeatStatus);
  assertEquals(tasklet.getStepContribution(), stepContribution);
}
origin: spring-projects/spring-batch

@Test(expected = java.util.concurrent.ExecutionException.class)
public void testExecuteException() throws Exception {
  String command = "non-sense-that-should-cause-exception-when-attempted-to-execute";
  tasklet.setCommand(command);
  tasklet.afterPropertiesSet();
  tasklet.execute(null, null);
}
origin: spring-projects/spring-batch

@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  initializeTasklet();
  tasklet.afterPropertiesSet();
  tasklet.beforeStep(stepExecution);
}
origin: spring-projects/spring-batch

  @Override
  public void run() {
    try {
      jobRepository.add(stepExecution);
      step.execute(stepExecution);
    }
    catch (JobInterruptedException e) {
      // do nothing...
    }
  }
};
origin: spring-projects/spring-batch

private TaskletStep getStep(String[] strings) throws Exception {
  return getStep(strings, 1);
}
origin: spring-projects/spring-batch

  @Override
  public void close() throws ItemStreamException {
    super.close();
    // Simulate failure on rollback when stream resets
    throw new RuntimeException("Bar");
  }
};
origin: spring-projects/spring-batch

  @Override
  public void update(ExecutionContext executionContext) {
            super.update(executionContext);
    executionContext.putString("foo", "bar");
  }
};
origin: spring-projects/spring-batch

@Test
public void testSameSignatureWithDifferentMethodName() throws Exception {
  adapter.setTargetMethod("execute1");
  RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext);
  assertEquals(RepeatStatus.FINISHED, repeatStatus);
  assertEquals(tasklet.getStepContribution(), stepContribution);
  assertEquals(tasklet.getChunkContext(), chunkContext);
}
origin: spring-projects/spring-batch

@Test
public void testArgumentSubsetWithOnlyChunkContextAndCompatibleReturnTypeVoid() throws Exception {
  adapter.setTargetMethod("execute9");
  RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext);
  assertEquals(RepeatStatus.FINISHED, repeatStatus);
  assertEquals(tasklet.getChunkContext(), chunkContext);
}
origin: spring-projects/spring-batch

@Test
public void testArgumentSubsetWithOnlyStepContribution() throws Exception {
  adapter.setTargetMethod("execute4");
  RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext);
  assertEquals(RepeatStatus.FINISHED, repeatStatus);
  assertEquals(tasklet.getStepContribution(), stepContribution);
}
origin: spring-projects/spring-batch

@Test
public void testExactlySameSignature() throws Exception {
  adapter.setTargetMethod("execute");
  RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext);
  assertEquals(RepeatStatus.FINISHED, repeatStatus);
  assertEquals(tasklet.getStepContribution(), stepContribution);
  assertEquals(tasklet.getChunkContext(), chunkContext);
}
org.springframework.batch.core.step.tasklet

Most used classes

  • TaskletStep
    Simple implementation of executing the step as a call to a Tasklet, possibly repeated, and each call
  • MethodInvokingTaskletAdapter
    A Tasklet that wraps a method in a POJO. By default the return value is ExitStatus#COMPLETED unless
  • SystemCommandException
    Exception indicating failed execution of system command.
  • SystemProcessExitCodeMapper
    Maps the exit code of a system process to ExitStatus value returned by a system command. Designed fo
  • Tasklet
    Strategy for processing in a step.
  • TaskletStep$ChunkTransactionCallback,
  • UncheckedTransactionException,
  • AsyncChunkOrientedStepIntegrationTests,
  • AsyncTaskletStepTests,
  • CallableTaskletAdapter,
  • ChunkOrientedStepIntegrationTests$2,
  • ChunkOrientedStepIntegrationTests,
  • ConfigurableSystemProcessExitCodeMapper,
  • ConfigurableSystemProcessExitCodeMapperTests$1,
  • MethodInvokingTaskletAdapterTest$TestTasklet,
  • SimpleSystemProcessExitCodeMapper,
  • StepExecutorInterruptionTests,
  • SystemCommandTasklet,
  • SystemCommandTaskletIntegrationTests
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