org.springframework.batch.core.resource
Class StepExecutionSimpleCompletionPolicy

java.lang.Object
  extended by org.springframework.batch.core.listener.StepExecutionListenerSupport
      extended by org.springframework.batch.core.resource.StepExecutionSimpleCompletionPolicy
All Implemented Interfaces:
StepExecutionListener, StepListener, org.springframework.batch.repeat.CompletionPolicy

public class StepExecutionSimpleCompletionPolicy
extends StepExecutionListenerSupport
implements org.springframework.batch.repeat.CompletionPolicy

A CompletionPolicy that picks up a commit interval from JobParameters by listening to the start of a step. Use anywhere that a CompletionPolicy can be used (usually at the chunk level in a step), and inject as a StepExecutionListener into the surrounding step. N.B. only after the step has started will the completion policy be usable.

Author:
Dave Syer
See Also:
CompletionPolicy

Constructor Summary
StepExecutionSimpleCompletionPolicy()
           
 
Method Summary
 void beforeStep(StepExecution stepExecution)
          Set up a SimpleCompletionPolicy with a commit interval taken from the JobParameters.
 boolean isComplete(org.springframework.batch.repeat.RepeatContext context)
           
 boolean isComplete(org.springframework.batch.repeat.RepeatContext context, org.springframework.batch.repeat.RepeatStatus result)
           
 void setKeyName(java.lang.String keyName)
          Public setter for the key name of a Long value in the JobParameters that will contain a commit interval.
 org.springframework.batch.repeat.RepeatContext start(org.springframework.batch.repeat.RepeatContext parent)
           
 java.lang.String toString()
          Delegates to the wrapped CompletionPolicy if set, otherwise returns the value of setKeyName(String).
 void update(org.springframework.batch.repeat.RepeatContext context)
           
 
Methods inherited from class org.springframework.batch.core.listener.StepExecutionListenerSupport
afterStep
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StepExecutionSimpleCompletionPolicy

public StepExecutionSimpleCompletionPolicy()
Method Detail

setKeyName

public void setKeyName(java.lang.String keyName)
Public setter for the key name of a Long value in the JobParameters that will contain a commit interval. Defaults to "commit.interval".

Parameters:
keyName - the keyName to set

beforeStep

public void beforeStep(StepExecution stepExecution)
Set up a SimpleCompletionPolicy with a commit interval taken from the JobParameters. If there is a Long parameter with the given key name, the intValue of this parameter is used. If not an exception will be thrown.

Specified by:
beforeStep in interface StepExecutionListener
Overrides:
beforeStep in class StepExecutionListenerSupport
See Also:
StepExecutionListenerSupport.beforeStep(org.springframework.batch.core.StepExecution)

isComplete

public boolean isComplete(org.springframework.batch.repeat.RepeatContext context,
                          org.springframework.batch.repeat.RepeatStatus result)
Specified by:
isComplete in interface org.springframework.batch.repeat.CompletionPolicy
Parameters:
context -
result -
Returns:
true if the commit interval has been reached or the result indicates completion
See Also:
CompletionPolicy.isComplete(RepeatContext, RepeatStatus)

isComplete

public boolean isComplete(org.springframework.batch.repeat.RepeatContext context)
Specified by:
isComplete in interface org.springframework.batch.repeat.CompletionPolicy
Parameters:
context -
Returns:
if the commit interval has been reached
See Also:
CompletionPolicy.isComplete(org.springframework.batch.repeat.RepeatContext)

start

public org.springframework.batch.repeat.RepeatContext start(org.springframework.batch.repeat.RepeatContext parent)
Specified by:
start in interface org.springframework.batch.repeat.CompletionPolicy
Parameters:
parent -
Returns:
a new RepeatContext
See Also:
CompletionPolicy.start(org.springframework.batch.repeat.RepeatContext)

update

public void update(org.springframework.batch.repeat.RepeatContext context)
Specified by:
update in interface org.springframework.batch.repeat.CompletionPolicy
Parameters:
context -
See Also:
CompletionPolicy.update(org.springframework.batch.repeat.RepeatContext)

toString

public java.lang.String toString()
Delegates to the wrapped CompletionPolicy if set, otherwise returns the value of setKeyName(String).

Overrides:
toString in class java.lang.Object


Copyright © 2009. All Rights Reserved.