/** * Get the next completed result, possibly executing several callbacks until * one finally finishes. Normally a subclass would have to override both * this method and {@link #createInternalState(RepeatContext)} because the * implementation of this method would rely on the details of the internal * state. * * @param context current BatchContext. * @param callback the callback to execute. * @param state maintained by the implementation. * @return a finished result. * @throws Throwable any Throwable emitted during the iteration * * @see #isComplete(RepeatContext) * @see #createInternalState(RepeatContext) */ protected RepeatStatus getNextResult(RepeatContext context, RepeatCallback callback, RepeatInternalState state) throws Throwable { update(context); if (logger.isDebugEnabled()) { logger.debug("Repeat operation about to start at count=" + context.getStartedCount()); } return callback.doInIteration(context); }
@Override public RepeatStatus iterate(RepeatCallback callback) { try { Object result = callback.doInIteration(null); calls.add(result); } catch (Exception e) { throw new RepeatException("Encountered exception in repeat.", e); } return RepeatStatus.CONTINUABLE; } });
/** * Execute the batch callback, and store the result, or any exception * that is thrown for retrieval later by caller. * * @see java.lang.Runnable#run() */ @Override public void run() { boolean clearContext = false; try { if (RepeatSynchronizationManager.getContext() == null) { clearContext = true; RepeatSynchronizationManager.register(context); } if (logger.isDebugEnabled()) { logger.debug("Repeat operation about to start at count=" + context.getStartedCount()); } result = callback.doInIteration(context); } catch (Throwable e) { error = e; } finally { if (clearContext) { RepeatSynchronizationManager.clear(); } queue.put(this); } }
/** * Get the next completed result, possibly executing several callbacks until * one finally finishes. Normally a subclass would have to override both * this method and {@link #createInternalState(RepeatContext)} because the * implementation of this method would rely on the details of the internal * state. * * @param context current BatchContext. * @param callback the callback to execute. * @param state maintained by the implementation. * @return a finished result. * @throws Throwable any Throwable emitted during the iteration * * @see #isComplete(RepeatContext) * @see #createInternalState(RepeatContext) */ protected RepeatStatus getNextResult(RepeatContext context, RepeatCallback callback, RepeatInternalState state) throws Throwable { update(context); if (logger.isDebugEnabled()) { logger.debug("Repeat operation about to start at count=" + context.getStartedCount()); } return callback.doInIteration(context); }
/** * Execute the batch callback, and store the result, or any exception * that is thrown for retrieval later by caller. * * @see java.lang.Runnable#run() */ @Override public void run() { boolean clearContext = false; try { if (RepeatSynchronizationManager.getContext() == null) { clearContext = true; RepeatSynchronizationManager.register(context); } if (logger.isDebugEnabled()) { logger.debug("Repeat operation about to start at count=" + context.getStartedCount()); } result = callback.doInIteration(context); } catch (Throwable e) { error = e; } finally { if (clearContext) { RepeatSynchronizationManager.clear(); } queue.put(this); } }