Class RepeatSynchronizationManager
- java.lang.Object
- org.springframework.batch.repeat.support.RepeatSynchronizationManager
public final class RepeatSynchronizationManager extends java.lang.ObjectGlobal variable support for repeat clients. Normally it is not necessary for clients to be aware of the surrounding environment because aRepeatCallbackcan always use the context it is passed by the enclosingRepeatOperations. But occasionally it might be helpful to have lower level access to the ongoingRepeatContextso we provide a global accessor here. The mutator methods (clear()andregister(RepeatContext)should not be used except internally byRepeatOperationsimplementations.- Author:
- Dave Syer
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RepeatContextclear()Clear the current context at the end of a batch - should only be used byRepeatOperationsimplementations.static RepeatContextgetContext()Getter for the current context.static RepeatContextregister(RepeatContext context)Method for registering a context - should only be used byRepeatOperationsimplementations to ensure thatgetContext()always returns the correct value.static voidsetAncestorsCompleteOnly()Set current session and all ancestors (via parent) to complete.,static voidsetCompleteOnly()Convenience method to set the current repeat operation to complete if it exists.
Method Detail
getContext
public static RepeatContext getContext()
Getter for the current context. A context is shared by all items in the batch, so this method is intended to return the same context object independent of whether the callback is running synchronously or asynchronously with the surroundingRepeatOperations.- Returns:
- the current
RepeatContextor null if there is none (if we are not in a batch).
setCompleteOnly
public static void setCompleteOnly()
Convenience method to set the current repeat operation to complete if it exists.
register
public static RepeatContext register(RepeatContext context)
Method for registering a context - should only be used byRepeatOperationsimplementations to ensure thatgetContext()always returns the correct value.- Parameters:
context- a new context at the start of a batch.- Returns:
- the old value if there was one.
clear
public static RepeatContext clear()
Clear the current context at the end of a batch - should only be used byRepeatOperationsimplementations.- Returns:
- the old value if there was one.
setAncestorsCompleteOnly
public static void setAncestorsCompleteOnly()
Set current session and all ancestors (via parent) to complete.,