/** * @see org.springframework.batch.core.listener.CompositeChunkListener#afterChunk(ChunkContext context) */ @Override public void afterChunk(ChunkContext context) { try { chunkListener.afterChunk(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in afterChunk.", getTargetException(e)); } }
/** * @see org.springframework.batch.core.listener.CompositeChunkListener#beforeChunk(ChunkContext context) */ @Override public void beforeChunk(ChunkContext context) { try { chunkListener.beforeChunk(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in beforeChunk.", getTargetException(e)); } }
/** * Register a chunk listener for callbacks at the appropriate stages in a * step execution. * * @param listener a {@link ChunkListener} */ public void registerChunkListener(ChunkListener listener) { this.chunkListener.register(listener); }
@Before public void setUp() throws Exception { chunkContext = new ChunkContext(null); listener = mock(ChunkListener.class); compositeListener = new CompositeChunkListener(); compositeListener.register(listener); }
@Override public void afterChunkError(ChunkContext context) { try { chunkListener.afterChunkError(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in afterFailedChunk.", e); } }
chunkListener.afterChunkError(chunkContext);
@Override public RepeatStatus doInChunkContext(RepeatContext repeatContext, ChunkContext chunkContext) throws Exception { StepExecution stepExecution = chunkContext.getStepContext().getStepExecution(); // Before starting a new transaction, check for // interruption. interruptionPolicy.checkInterrupted(stepExecution); RepeatStatus result; try { result = new TransactionTemplate(transactionManager, transactionAttribute) .execute(new ChunkTransactionCallback(chunkContext, semaphore)); } catch (UncheckedTransactionException e) { // Allow checked exceptions to be thrown inside callback throw (Exception) e.getCause(); } chunkListener.afterChunk(chunkContext); // Check for interruption after transaction as well, so that // the interrupted exception is correctly propagated up to // caller interruptionPolicy.checkInterrupted(stepExecution); return result == null ? RepeatStatus.FINISHED : result; }
@Test public void testBeforeChunk(){ listener.beforeChunk(chunkContext); compositeListener.beforeChunk(chunkContext); }
this.chunkListener.register((ChunkListener) listener);
@Test public void testAfterChunkFailed(){ ChunkContext context = new ChunkContext(null); listener.afterChunkError(context); compositeListener.afterChunkError(context); } }
@Test public void testAfterChunk(){ listener.afterChunk(chunkContext); compositeListener.afterChunk(chunkContext); }
chunkListener.beforeChunk(chunkContext);
/** * Register a chunk listener for callbacks at the appropriate stages in a * step execution. * * @param listener a {@link ChunkListener} */ public void registerChunkListener(ChunkListener listener) { this.chunkListener.register(listener); }
@Override public void afterChunkError(ChunkContext context) { try { chunkListener.afterChunkError(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in afterFailedChunk.", e); } }
/** * * @see org.springframework.batch.core.listener.CompositeChunkListener#afterChunk() */ public void afterChunk() { try { chunkListener.afterChunk(); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in afterChunk.", e); } }
/** * * @see org.springframework.batch.core.listener.CompositeChunkListener#beforeChunk() */ public void beforeChunk() { try { chunkListener.beforeChunk(); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in beforeChunk.", e); } }
/** * Register a chunk listener for callbacks at the appropriate stages in a * step execution. * * @param listener a {@link ChunkListener} */ public void registerChunkListener(ChunkListener listener) { this.chunkListener.register(listener); }
@Override public void afterChunkError(ChunkContext context) { try { chunkListener.afterChunkError(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in afterFailedChunk.", e); } }
/** * * @see org.springframework.batch.core.listener.CompositeChunkListener#afterChunk(ChunkContext context) */ @Override public void afterChunk(ChunkContext context) { try { chunkListener.afterChunk(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in afterChunk.", e); } }
/** * * @see org.springframework.batch.core.listener.CompositeChunkListener#beforeChunk(ChunkContext context) */ @Override public void beforeChunk(ChunkContext context) { try { chunkListener.beforeChunk(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in beforeChunk.", e); } }