public class TaskletStep extends AbstractStep
Tasklet
,
possibly repeated, and each call surrounded by a transaction. The structure
is therefore that of a loop with transaction boundary inside the loop. The
loop is controlled by the step operations (
setStepOperations(RepeatOperations)
).Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TASKLET_TYPE_KEY |
STEP_TYPE_KEY
Constructor and Description |
---|
TaskletStep()
Default constructor.
|
TaskletStep(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected void |
close(ExecutionContext ctx)
Extension point for subclasses to provide callbacks to their collaborators at the end of a step (right at the end
of the finally block), to close or release resources.
|
protected java.util.concurrent.Semaphore |
createSemaphore()
Extension point mainly for test purposes so that the behaviour of the
lock can be manipulated to simulate various pathologies.
|
protected void |
doExecute(StepExecution stepExecution)
Process the step and update its context so that progress can be monitored
by the caller.
|
Tasklet |
getTasklet()
retrieve the tasklet - helper method for JobOperator
|
protected void |
open(ExecutionContext ctx)
Extension point for subclasses to provide callbacks to their collaborators at the beginning of a step, to open or
acquire resources.
|
void |
registerChunkListener(ChunkListener listener)
Register a chunk listener for callbacks at the appropriate stages in a
step execution.
|
void |
registerStream(ItemStream stream)
Register a single
ItemStream for callbacks to the stream
interface. |
void |
setChunkListeners(ChunkListener[] listeners)
Register each of the objects as listeners.
|
void |
setInterruptionPolicy(StepInterruptionPolicy interruptionPolicy)
Setter for the
StepInterruptionPolicy . |
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 |
setTasklet(Tasklet tasklet)
Public setter for the
Tasklet . |
void |
setTransactionAttribute(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute)
Public setter for the
TransactionAttribute . |
void |
setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Public setter for the
PlatformTransactionManager . |
doExecutionRegistration, doExecutionRelease, execute, getCompositeListener, getJobRepository, getName, getStartLimit, isAllowStartIfComplete, registerStepExecutionListener, setAllowStartIfComplete, setBeanName, setJobRepository, setName, setStartLimit, setStepExecutionListeners, toString
public static final java.lang.String TASKLET_TYPE_KEY
public TaskletStep()
public TaskletStep(java.lang.String name)
name
- public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class AbstractStep
java.lang.Exception
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
PlatformTransactionManager
.transactionManager
- the transaction manager to setpublic void setTransactionAttribute(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute)
TransactionAttribute
.transactionAttribute
- the TransactionAttribute
to setpublic void setTasklet(Tasklet tasklet)
Tasklet
.tasklet
- the Tasklet
to setpublic void registerChunkListener(ChunkListener listener)
listener
- a ChunkListener
public void setChunkListeners(ChunkListener[] listeners)
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 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
protected void doExecute(StepExecution stepExecution) throws java.lang.Exception
BatchStatus
, and the JobRepository
is
used to store the result. Various reporting information are also added to
the current context governing the step execution, which would normally be
available to the caller through the step's ExecutionContext
.doExecute
in class AbstractStep
stepExecution
- the current step contextJobInterruptedException
- if the step or a chunk is interruptedjava.lang.RuntimeException
- if there is an exception during a chunk
executionjava.lang.Exception
protected java.util.concurrent.Semaphore createSemaphore()
protected void close(ExecutionContext ctx) throws java.lang.Exception
AbstractStep
close
in class AbstractStep
ctx
- the ExecutionContext
to usejava.lang.Exception
protected void open(ExecutionContext ctx) throws java.lang.Exception
AbstractStep
open
in class AbstractStep
ctx
- the ExecutionContext
to usejava.lang.Exception