/** * True if the result is null, or a {@link RepeatStatus} indicating * completion. * * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext, * RepeatStatus) */ @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { return (result == null || !result.isContinuable()); }
@Override public void after(RepeatContext context, RepeatStatus result) { for (RepeatListener listener : listeners) { listener.after(context, result); } }
/** * Delegate to the {@link CompletionPolicy}. * @param context the value returned by start. * * @see org.springframework.batch.repeat.CompletionPolicy#update(RepeatContext) */ protected void update(RepeatContext context) { completionPolicy.update(context); }
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count <= 1); } });
/** * Simply calls template.execute(callback). Clients can use this to repeat a * batch process, or to break a process up into smaller chunks (e.g. to * change the transaction boundaries). * * @see org.springframework.batch.repeat.RepeatCallback#doInIteration(RepeatContext) */ @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { return template.iterate(callback); } }
/** * Convenience method to execute after interceptors on a callback result. * * @param context the current batch context. * @param value the result of the callback to process. */ protected void executeAfterInterceptors(final RepeatContext context, RepeatStatus value) { // Don't re-throw exceptions here: let the exception handler deal with // that... if (value != null && value.isContinuable()) { for (int i = listeners.length; i-- > 0;) { RepeatListener interceptor = listeners[i]; interceptor.after(context, value); } } }
@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; } });
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { throw new RepeatException("typically thrown by nested repeat template", exception); } });
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; context.setCompleteOnly(); return RepeatStatus.FINISHED; } });
@Override public void close(RepeatContext context) { for (RepeatListener listener : listeners) { listener.close(context); } }
@Override public void open(RepeatContext context) { for (RepeatListener listener : listeners) { listener.open(context); } }
@Override public void onError(RepeatContext context, Throwable e) { for (RepeatListener listener : listeners) { listener.onError(context, e); } }
@Override public void before(RepeatContext context) { for (RepeatListener listener : listeners) { listener.before(context); } }
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count < 1); } });
/** * Check return value from batch operation. * * @param value the last callback result. * @return true if the value is {@link RepeatStatus#CONTINUABLE}. */ protected final boolean canContinue(RepeatStatus value) { return value.isContinuable(); }
@Override public Exception getException(String msg) throws Exception { return new RepeatException(msg); }
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count <= 1); } });
@Override public Exception getException(String msg, Throwable t) throws Exception { return new RepeatException(msg, t); }
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count < 2); } });
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count <= 1); } });