org.springframework.batch.repeat
Interface CompletionPolicy

All Known Implementing Classes:
CompletionPolicySupport, CompositeCompletionPolicy, CountingCompletionPolicy, DefaultResultCompletionPolicy, SimpleCompletionPolicy, StepExecutionSimpleCompletionPolicy, TimeoutTerminationPolicy

public interface CompletionPolicy

Interface for batch completion policies, to enable batch operations to strategise normal completion conditions. Stateful implementations of batch iterators should only update state using the update method. If you need custom behaviour consider extending an existing implementation or using the composite provided.

Author:
Dave Syer

Method Summary
 boolean isComplete(RepeatContext context)
          Allow policy to signal completion according to internal state, without having to wait for the callback to complete.
 boolean isComplete(RepeatContext context, ExitStatus result)
          Determine whether a batch is complete given the latest result from the callback.
 RepeatContext start(RepeatContext parent)
          Create a new context for the execution of a batch.
 void update(RepeatContext context)
          Give implementations the opportunity to update the state of the current batch.
 

Method Detail

isComplete

boolean isComplete(RepeatContext context,
                   ExitStatus result)
Determine whether a batch is complete given the latest result from the callback. If this method returns true then isComplete(RepeatContext) should also (but not necessarily vice versa, since the answer here depends on the result).

Parameters:
context - the current batch context.
result - the result of the latest batch item processing.
Returns:
true if the batch should terminate.
See Also:
isComplete(RepeatContext)

isComplete

boolean isComplete(RepeatContext context)
Allow policy to signal completion according to internal state, without having to wait for the callback to complete.

Parameters:
context - the current batch context.
Returns:
true if the batch should terminate.

start

RepeatContext start(RepeatContext parent)
Create a new context for the execution of a batch. N.B. implementations should not return the parent from this method - they must create a new context to meet the specific needs of the policy. The best way to do this might be to override an existing implementation and use the RepeatContext to store state in its attributes.

Parameters:
parent - the current context if one is already in progress.
Returns:
a context object that can be used by the implementation to store internal state for a batch.

update

void update(RepeatContext context)
Give implementations the opportunity to update the state of the current batch. Will be called once per callback, after it has been launched, but not necessarily after it completes (if the batch is asynchronous).

Parameters:
context - the value returned by start.


Copyright © 2009 SpringSource. All Rights Reserved.