Class CompositeCompletionPolicy
- java.lang.Object
- org.springframework.batch.repeat.policy.CompositeCompletionPolicy
- All Implemented Interfaces:
CompletionPolicy
public class CompositeCompletionPolicy extends java.lang.Object implements CompletionPolicy
Composite policy that loops through a list of delegate policies and answers calls by a consensus.- Author:
- Dave Syer
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
CompositeCompletionPolicy.CompositeBatchContext
Composite context that knows about the policies and contexts is was created with.
Constructor Summary
Constructors Constructor Description CompositeCompletionPolicy()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isComplete(RepeatContext context)
This policy is complete if any of the composed policies is complete.boolean
isComplete(RepeatContext context, RepeatStatus result)
This policy is complete if any of the composed policies is complete.void
setPolicies(CompletionPolicy[] policies)
Setter for the policies.RepeatContext
start(RepeatContext context)
Create a new composite context from all the available policies.void
update(RepeatContext context)
Update all the composed contexts, and also increment the parent context.
Method Detail
setPolicies
public void setPolicies(CompletionPolicy[] policies)
Setter for the policies.- Parameters:
policies
- an array of completion policies to be used to determineisComplete(RepeatContext)
by consensus.
isComplete
public boolean isComplete(RepeatContext context, RepeatStatus result)
This policy is complete if any of the composed policies is complete.- Specified by:
isComplete
in interfaceCompletionPolicy
- Parameters:
context
- the current batch context.result
- the result of the latest batch item processing.- Returns:
- true if the batch should terminate.
- See Also:
CompletionPolicy.isComplete(org.springframework.batch.repeat.RepeatContext, RepeatStatus)
isComplete
public boolean isComplete(RepeatContext context)
This policy is complete if any of the composed policies is complete.- Specified by:
isComplete
in interfaceCompletionPolicy
- Parameters:
context
- the current batch context.- Returns:
- true if the batch should terminate.
- See Also:
CompletionPolicy.isComplete(org.springframework.batch.repeat.RepeatContext)
start
public RepeatContext start(RepeatContext context)
Create a new composite context from all the available policies.- Specified by:
start
in interfaceCompletionPolicy
- Parameters:
context
- 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.
- See Also:
CompletionPolicy.start(RepeatContext)
update
public void update(RepeatContext context)
Update all the composed contexts, and also increment the parent context.- Specified by:
update
in interfaceCompletionPolicy
- Parameters:
context
- the value returned by start.- See Also:
CompletionPolicy.update(org.springframework.batch.repeat.RepeatContext)