下面列出了怎么用org.springframework.batch.core.ItemReadListener的API类实例代码及写法,或者点击链接到github查看源代码。
@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);
}
@Bean
@ConditionalOnProperty(prefix = "spring.cloud.task.batch.events.item-read",
name = "enabled", havingValue = "true", matchIfMissing = true)
// @checkstyle:on
public ItemReadListener itemReadEventsListener() {
return new EventEmittingItemReadListener(
this.listenerChannels.itemReadEvents(),
this.taskEventProperties.getItemReadOrder());
}
private void registerItemReadEvents(SimpleChunkProvider chunkProvider) {
if (this.applicationContext
.containsBean(BatchEventAutoConfiguration.ITEM_READ_EVENTS_LISTENER)) {
chunkProvider.registerListener((ItemReadListener) this.applicationContext
.getBean(BatchEventAutoConfiguration.ITEM_READ_EVENTS_LISTENER));
}
}