List of usage examples for org.springframework.batch.repeat.support RepeatSynchronizationManager getContext
public static RepeatContext getContext()
From source file:org.springframework.batch.core.step.item.SimpleRetryExceptionHandler.java
/** * Get the parent context (the retry is in an inner "chunk" loop and we want * the exception to be handled at the outer "step" level). * @return the {@link RepeatContext} that should hold the exhausted flag. *//*from w w w . ja v a2 s . c o m*/ private RepeatContext getRepeatContext() { RepeatContext context = RepeatSynchronizationManager.getContext(); if (context.getParent() != null) { return context.getParent(); } return context; }
From source file:org.springframework.batch.repeat.support.RepeatTemplate.java
/** * Execute the batch callback until the completion policy decides that we * are finished. Wait for the whole batch to finish before returning even if * the task executor is asynchronous./*w ww. j a v a 2s .c o m*/ * * @see org.springframework.batch.repeat.RepeatOperations#iterate(org.springframework.batch.repeat.RepeatCallback) */ @Override public RepeatStatus iterate(RepeatCallback callback) { RepeatContext outer = RepeatSynchronizationManager.getContext(); RepeatStatus result = RepeatStatus.CONTINUABLE; try { // This works with an asynchronous TaskExecutor: the // interceptors have to wait for the child processes. result = executeInternal(callback); } finally { RepeatSynchronizationManager.clear(); if (outer != null) { RepeatSynchronizationManager.register(outer); } } return result; }
From source file:org.springframework.batch.repeat.support.RepeatTemplate.java
/** * Delegate to the {@link CompletionPolicy}. * /*www. j a v a2 s .co m*/ * @see org.springframework.batch.repeat.CompletionPolicy#start(RepeatContext) */ protected RepeatContext start() { RepeatContext parent = RepeatSynchronizationManager.getContext(); RepeatContext context = completionPolicy.start(parent); RepeatSynchronizationManager.register(context); logger.debug("Starting repeat context."); return context; }