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.AttributeAccessor
Base interface for context which controls the state and completion / termination of a
batch step. A new context is created for each call to the
RepeatOperations
.
Within a batch callback code can communicate via the AttributeAccessor
interface.- Author:
- Dave Syer
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Allow resources to be cleared, especially in destruction callbacks.If batches are nested, then the inner batch will be created with the outer one as a parent.int
Public access to a counter for the number of operations attempted.boolean
Public accessor for the complete flag.boolean
Public accessor for the termination flag.void
registerDestructionCallback
(String name, Runnable callback) Register a callback to be executed on close, associated with the attribute having the given name.void
Signal to the framework that the current batch should complete normally, independent of the currentCompletionPolicy
.void
Signal to the framework that the current batch should complete abnormally, independent of the currentCompletionPolicy
.Methods inherited from interface org.springframework.core.AttributeAccessor
attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttribute
-
Method Details
-
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
Register a callback to be executed on close, associated with the attribute having the given name. TheRunnable
callback 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
- aRunnable
to 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.
-