Package org.springframework.batch.repeat
Interface RepeatContext
- All Superinterfaces:
org.springframework.core.AttributeAccessor
- All Known Implementing Classes:
CompositeCompletionPolicy.CompositeBatchContext,CountingCompletionPolicy.CountingBatchContext,RepeatContextSupport,SimpleCompletionPolicy.SimpleTerminationContext,TimeoutTerminationPolicy.TimeoutBatchContext
public interface RepeatContext extends org.springframework.core.AttributeAccessorBase interface for context which controls the state and completion / termination of a batch step. A new context is created for each call to theRepeatOperations. Within a batch callback code can communicate via theAttributeAccessorinterface.- Author:
- Dave Syer
- See Also:
RepeatOperations.iterate(RepeatCallback)
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Allow resources to be cleared, especially in destruction callbacks.RepeatContextgetParent()If batches are nested, then the inner batch will be created with the outer one as a parent.intgetStartedCount()Public access to a counter for the number of operations attempted.booleanisCompleteOnly()Public accessor for the complete flag.booleanisTerminateOnly()Public accessor for the termination flag.voidregisterDestructionCallback(java.lang.String name, java.lang.Runnable callback)Register a callback to be executed on close, associated with the attribute having the given name.voidsetCompleteOnly()Signal to the framework that the current batch should complete normally, independent of the currentCompletionPolicy.voidsetTerminateOnly()Signal to the framework that the current batch should complete abnormally, independent of the currentCompletionPolicy.
Method Detail
getParent
RepeatContext getParent()
If batches are nested, then the inner batch will be created with the outer one as a parent. This is an accessor for the parent if it exists.- Returns:
- the parent context or null if there is none
getStartedCount
int getStartedCount()
Public access to a counter for the number of operations attempted.- Returns:
- the number of batch operations started.
setCompleteOnly
void setCompleteOnly()
Signal to the framework that the current batch should complete normally, independent of the currentCompletionPolicy.
isCompleteOnly
boolean isCompleteOnly()
Public accessor for the complete flag.- Returns:
- indicator if the repeat is complete
setTerminateOnly
void setTerminateOnly()
Signal to the framework that the current batch should complete abnormally, independent of the currentCompletionPolicy.
isTerminateOnly
boolean isTerminateOnly()
Public accessor for the termination flag. If this flag is set then the complete flag will also be.- Returns:
- indicates if the repeat should terminate
registerDestructionCallback
void registerDestructionCallback(java.lang.String name, java.lang.Runnable callback)Register a callback to be executed on close, associated with the attribute having the given name. TheRunnablecallback should not throw any exceptions.- Parameters:
name- the name of the attribute to associated this callback with. If this attribute is removed the callback should never be called.callback- aRunnableto execute when the context is closed.
close
void close()
Allow resources to be cleared, especially in destruction callbacks. Implementations should ensure that any registered destruction callbacks are executed here, as long as the corresponding attribute is still available.