|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.batch.core.step.AbstractStep
org.springframework.batch.core.step.item.ItemOrientedStep
public class ItemOrientedStep
Simple implementation of executing the step as a set of chunks, each chunk
surrounded by a transaction. The structure is therefore that of two nested
loops, with transaction boundary around the whole inner loop. The outer loop
is controlled by the step operations (setStepOperations(RepeatOperations)
),
and the inner loop by the chunk operations (setChunkOperations(RepeatOperations)
).
The inner loop should always be executed in a single thread, so the chunk
operations should not do any concurrent execution. N.B. usually that means
that the chunk operations should be a RepeatTemplate
(which is the
default).
Clients can use interceptors in the step operations to intercept or listen to
the iteration on a step-wide basis, for instance to get a callback when the
step is complete. Those that want callbacks at the level of an individual
tasks, can specify interceptors for the chunk operations.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.springframework.batch.core.step.AbstractStep |
---|
AbstractStep.FatalException |
Field Summary |
---|
Fields inherited from class org.springframework.batch.core.step.AbstractStep |
---|
JOB_INTERRUPTED |
Constructor Summary | |
---|---|
ItemOrientedStep(String name)
|
Method Summary | |
---|---|
protected void |
close(ExecutionContext ctx)
|
protected ExitStatus |
doExecute(StepExecution stepExecution)
Process the step and update its context so that progress can be monitored by the caller. |
protected void |
open(ExecutionContext ctx)
|
protected ExitStatus |
processChunk(StepExecution execution,
StepContribution contribution)
Execute a bunch of identical business logic operations all within a transaction. |
void |
registerStream(ItemStream stream)
Register a single ItemStream for callbacks to the stream
interface. |
void |
setChunkOperations(RepeatOperations chunkOperations)
The RepeatOperations to use for the inner loop of the batch
processing. |
void |
setInterruptionPolicy(StepInterruptionPolicy interruptionPolicy)
Setter for the StepInterruptionPolicy . |
void |
setItemHandler(ItemHandler itemHandler)
Public setter for the ItemHandler . |
void |
setStepExecutionListeners(StepExecutionListener[] listeners)
Register each of the objects as listeners. |
void |
setStepOperations(RepeatOperations stepOperations)
The RepeatOperations to use for the outer loop of the batch
processing. |
void |
setStreams(ItemStream[] streams)
Register each of the streams for callbacks at the appropriate time in the step. |
void |
setSynchronizer(StepExecutionSynchronizer synchronizer)
Mostly useful for testing, but could be used to remove dependence on backport concurrency utilities. |
void |
setTransactionManager(PlatformTransactionManager transactionManager)
Public setter for the PlatformTransactionManager . |
Methods inherited from class org.springframework.batch.core.step.AbstractStep |
---|
afterPropertiesSet, execute, getCompositeListener, getJobRepository, getName, getStartLimit, isAllowStartIfComplete, registerStepExecutionListener, setAllowStartIfComplete, setBeanName, setJobRepository, setName, setStartLimit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ItemOrientedStep(String name)
name
- Method Detail |
---|
public void setTransactionManager(PlatformTransactionManager transactionManager)
PlatformTransactionManager
.
transactionManager
- the transaction manager to setpublic void setItemHandler(ItemHandler itemHandler)
ItemHandler
.
itemHandler
- the ItemHandler
to setpublic void setStepExecutionListeners(StepExecutionListener[] listeners)
ItemReader
or
ItemWriter
themselves implements this interface they will be
registered automatically, but their injected dependencies will not be.
This is a good way to get access to job parameters and execution context
if the tasklet is parameterised.
setStepExecutionListeners
in class AbstractStep
listeners
- an array of listener objects of known types.public void setStreams(ItemStream[] streams)
ItemReader
and ItemWriter
are automatically
registered, but it doesn't hurt to also register them here. Injected
dependencies of the reader and writer are not automatically registered,
so if you implement ItemWriter
using delegation to another object
which itself is a ItemStream
, you need to register the delegate
here.
streams
- an array of ItemStream
objects.public void registerStream(ItemStream stream)
ItemStream
for callbacks to the stream
interface.
stream
- public void setStepOperations(RepeatOperations stepOperations)
RepeatOperations
to use for the outer loop of the batch
processing. Should be set up by the caller through a factory. Defaults to
a plain RepeatTemplate
.
stepOperations
- a RepeatOperations
instance.public void setChunkOperations(RepeatOperations chunkOperations)
RepeatOperations
to use for the inner loop of the batch
processing. should be set up by the caller through a factory. defaults to
a plain RepeatTemplate
.
chunkOperations
- a RepeatOperations
instance.public void setInterruptionPolicy(StepInterruptionPolicy interruptionPolicy)
StepInterruptionPolicy
. The policy is used to
check whether an external request has been made to interrupt the job
execution.
interruptionPolicy
- a StepInterruptionPolicy
public void setSynchronizer(StepExecutionSynchronizer synchronizer)
StepExecutionSynchronizer
.
synchronizer
- the StepExecutionSynchronizer
to setprotected ExitStatus doExecute(StepExecution stepExecution) throws Exception
BatchStatus
, and the JobRepository
is used to store the result. Various reporting information are also added
to the current context (the RepeatContext
governing the step
execution, which would normally be available to the caller somehow
through the step's ExecutionContext
.
doExecute
in class AbstractStep
JobInterruptedException
- if the step or a chunk is interrupted
RuntimeException
- if there is an exception during a chunk
execution
Exception
protected ExitStatus processChunk(StepExecution execution, StepContribution contribution)
execution
- the current StepExecution
which should be
treated as read-only for the purposes of this method.contribution
- the current StepContribution
which can accept
changes to be aggregated later into the step execution.
protected void close(ExecutionContext ctx) throws Exception
close
in class AbstractStep
Exception
protected void open(ExecutionContext ctx) throws Exception
open
in class AbstractStep
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |