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(); }
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); } }
@Before public void setupMock() { when(taskletStep.getTasklet()).thenReturn( new ChunkOrientedTasklet(chunkProvider, chunkProcessor)); when(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); }
@Bean public StepExecutionListener composedTaskStepExecutionListener( TaskConfigurer taskConfigurer) { return new ComposedTaskStepExecutionListener(taskConfigurer.getTaskExplorer()); }
@Bean @ConditionalOnProperty(prefix = "spring.cloud.task.batch.events.step-execution", name = "enabled", havingValue = "true", matchIfMissing = true) public StepExecutionListener stepExecutionEventsListener() { return new EventEmittingStepExecutionListener(listenerChannels.stepExecutionEvents(),taskEventProperties.getStepExecutionOrder()); }
@Override public Set<StepExecutionListener> stepExecutionListeners() { Set<StepExecutionListener> listeners = new HashSet<StepExecutionListener>(); listeners.add(metricsListener()); return listeners; }
@Override public Set<StepExecutionListener> stepExecutionListeners() { return new HashSet<StepExecutionListener>(); }
/** * 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();