/** * @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)); } }
@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 testAfterChunk(){ listener.afterChunk(chunkContext); compositeListener.afterChunk(chunkContext); }
/** * * @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#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#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#afterChunk(ChunkContext context) */ @Override public void afterChunk(ChunkContext context) { try { chunkListener.afterChunk(context); } catch (RuntimeException e) { throw new StepListenerFailedException("Error in afterChunk.", getTargetException(e)); } }
@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; }
@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; }
@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; }
@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 = (RepeatStatus) new TransactionTemplate(transactionManager, transactionAttribute) .execute(new ChunkTransactionCallback(chunkContext)); } catch (UncheckedTransactionException e) { // Allow checked exceptions to be thrown inside callback throw (Exception) e.getCause(); } chunkListener.afterChunk(); // Check for interruption after transaction as well, so that // the interrupted exception is correctly propagated up to // caller interruptionPolicy.checkInterrupted(stepExecution); return result; }