org.springframework.batch.core.StepExecutionListener Java Examples

The following examples show how to use org.springframework.batch.core.StepExecutionListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskBatchEventListenerBeanPostProcessorTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Before
public void setupMock() {
	when(this.taskletStep.getTasklet()).thenReturn(
			new ChunkOrientedTasklet(this.chunkProvider, this.chunkProcessor));
	when(this.taskletStep.getName()).thenReturn("FOOOBAR");

	registerAlias(ItemProcessListener.class,
			BatchEventAutoConfiguration.ITEM_PROCESS_EVENTS_LISTENER);
	registerAlias(StepExecutionListener.class,
			BatchEventAutoConfiguration.STEP_EXECUTION_EVENTS_LISTENER);
	registerAlias(ChunkListener.class,
			BatchEventAutoConfiguration.CHUNK_EVENTS_LISTENER);
	registerAlias(ItemReadListener.class,
			BatchEventAutoConfiguration.ITEM_READ_EVENTS_LISTENER);
	registerAlias(ItemWriteListener.class,
			BatchEventAutoConfiguration.ITEM_WRITE_EVENTS_LISTENER);
	registerAlias(SkipListener.class,
			BatchEventAutoConfiguration.SKIP_EVENTS_LISTENER);
}
 
Example #2
Source File: ComposedRunnerVisitorConfiguration.java    From composed-task-runner with Apache License 2.0 5 votes vote down vote up
private Step createTaskletStepWithListener(final String taskName,
		StepExecutionListener stepExecutionListener) {
	return this.steps.get(taskName)
			.tasklet(new Tasklet() {
				@Override
				public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
					return RepeatStatus.FINISHED;
				}
			})
			.transactionAttribute(getTransactionAttribute())
			.listener(stepExecutionListener)
			.build();
}
 
Example #3
Source File: SpringBatchFlowRunner.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
private StepExecutionListener releaserListener(NamedArgumentsSupplier argsSupplier,
		ReleaserTask releaserTask) {
	return new StepExecutionListenerSupport() {
		@Override
		public ExitStatus afterStep(StepExecution stepExecution) {
			Arguments args = argsSupplier.get();
			FlowRunner.Decision decision = afterTask(args.options, args.properties,
					releaserTask);
			if (decision == FlowRunner.Decision.ABORT) {
				return ExitStatus.FAILED;
			}
			ExecutionResult result = (ExecutionResult) stepExecution
					.getExecutionContext().get("result");
			if (result == null || result.isSuccess()) {
				return stepExecution.getExitStatus();
			}
			else if (result.isUnstable()) {
				return ExitStatus.COMPLETED
						.addExitDescription(BuildUnstableException.DESCRIPTION);
			}
			else if (result.isFailure()) {
				return ExitStatus.FAILED;
			}
			return ExitStatus.COMPLETED;
		}
	};
}
 
Example #4
Source File: ComposedRunnerVisitorConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private Step createTaskletStepWithListener(final String taskName,
		StepExecutionListener stepExecutionListener) {
	return this.steps.get(taskName)
			.tasklet(new Tasklet() {
				@Override
				public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
					return RepeatStatus.FINISHED;
				}
			})
			.transactionAttribute(getTransactionAttribute())
			.listener(stepExecutionListener)
			.build();
}
 
Example #5
Source File: BatchEventAutoConfiguration.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnProperty(prefix = "spring.cloud.task.batch.events.step-execution",
		name = "enabled", havingValue = "true", matchIfMissing = true)
// @checkstyle:on
public StepExecutionListener stepExecutionEventsListener() {
	return new EventEmittingStepExecutionListener(
			this.listenerChannels.stepExecutionEvents(),
			this.taskEventProperties.getStepExecutionOrder());
}
 
Example #6
Source File: TaskBatchEventListenerBeanPostProcessor.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void registerStepExecutionEventListener(Object bean) {
	if (this.applicationContext.containsBean(
			BatchEventAutoConfiguration.STEP_EXECUTION_EVENTS_LISTENER)) {
		StepExecutionListener stepExecutionListener = (StepExecutionListener) this.applicationContext
				.getBean(BatchEventAutoConfiguration.STEP_EXECUTION_EVENTS_LISTENER);
		AbstractStep step = (AbstractStep) bean;
		step.registerStepExecutionListener(stepExecutionListener);
	}
}
 
Example #7
Source File: ComposedTaskRunnerConfiguration.java    From composed-task-runner with Apache License 2.0 4 votes vote down vote up
@Bean
public StepExecutionListener composedTaskStepExecutionListener(TaskExplorer taskExplorer){
	return new ComposedTaskStepExecutionListener(taskExplorer);
}
 
Example #8
Source File: ComposedTaskRunnerConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public StepExecutionListener composedTaskStepExecutionListener(TaskExplorer taskExplorer){
	return new org.springframework.cloud.dataflow.composedtaskrunner.ComposedTaskStepExecutionListener(taskExplorer);
}
 
Example #9
Source File: MetricsConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 4 votes vote down vote up
@Override
public Set<StepExecutionListener> stepExecutionListeners() {
	Set<StepExecutionListener> listeners = new HashSet<>();
	listeners.add(metricsListener());
	return listeners;
}
 
Example #10
Source File: TestListenerConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 4 votes vote down vote up
@Override
public Set<StepExecutionListener> stepExecutionListeners() {
	return new HashSet<StepExecutionListener>();
}
 
Example #11
Source File: ListenerProvider.java    From spring-boot-starter-batch-web with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a set of StepExecutionListeners that will be added to each Job. May not return null.
 * 
 * @return Returns a set of StepExecutionListeners that will be added to each Job. May not return null.
 */
public Set<StepExecutionListener> stepExecutionListeners();