org.springframework.batch.core.scope.context
Class StepContextRepeatCallback

java.lang.Object
  extended by org.springframework.batch.core.scope.context.StepContextRepeatCallback
All Implemented Interfaces:
org.springframework.batch.repeat.RepeatCallback

public abstract class StepContextRepeatCallback
extends java.lang.Object
implements org.springframework.batch.repeat.RepeatCallback

Convenient base class for clients who need to do something in a repeat callback inside a Step.

Author:
Dave Syer

Constructor Summary
StepContextRepeatCallback(StepExecution stepExecution)
           
 
Method Summary
abstract  org.springframework.batch.repeat.RepeatStatus doInChunkContext(org.springframework.batch.repeat.RepeatContext context, ChunkContext chunkContext)
          Do the work required for this chunk of the step.
 org.springframework.batch.repeat.RepeatStatus doInIteration(org.springframework.batch.repeat.RepeatContext context)
          Manage the StepContext lifecycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StepContextRepeatCallback

public StepContextRepeatCallback(StepExecution stepExecution)
Parameters:
stepExecution -
Method Detail

doInIteration

public org.springframework.batch.repeat.RepeatStatus doInIteration(org.springframework.batch.repeat.RepeatContext context)
                                                            throws java.lang.Exception
Manage the StepContext lifecycle. Business processing should be delegated to doInChunkContext(RepeatContext, ChunkContext). This is to ensure that the current thread has a reference to the context, even if the callback is executed in a pooled thread. Handles the registration and de-registration of the step context, so clients should not duplicate those calls.

Specified by:
doInIteration in interface org.springframework.batch.repeat.RepeatCallback
Throws:
java.lang.Exception
See Also:
RepeatCallback.doInIteration(RepeatContext)

doInChunkContext

public abstract org.springframework.batch.repeat.RepeatStatus doInChunkContext(org.springframework.batch.repeat.RepeatContext context,
                                                                               ChunkContext chunkContext)
                                                                        throws java.lang.Exception
Do the work required for this chunk of the step. The ChunkContext provided is managed by the base class, so that if there is still work to do for the task in hand state can be stored here. In a multi-threaded client, the base class ensures that only one thread at a time can be working on each instance of ChunkContext. Workers should signal that they are finished with a context by removing all the attributes they have added. If a worker does not remove them another thread might see stale state.

Parameters:
context - the current RepeatContext
chunkContext - the chunk context in which to carry out the work
Returns:
the repeat status from the execution
Throws:
java.lang.Exception - implementations can throw an exception if anything goes wrong


Copyright © 2009. All Rights Reserved.