类 TaskletStep
- java.lang.Object
- org.springframework.batch.core.step.AbstractStep
- org.springframework.batch.core.step.tasklet.TaskletStep
- 所有已实现的接口:
Step
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.InitializingBean
- 直接已知子类:
BatchletStep
public class TaskletStep extends AbstractStep
Simple implementation of executing the step as a call to aTasklet
, 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)
).
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.- 作者:
- Dave Syer, Lucas Ward, Ben Hale, Robert Kasanicky, Michael Minella, Will Schipp, Mahmoud Ben Hassine
字段概要
字段 修饰符和类型 字段 说明 static java.lang.String
TASKLET_TYPE_KEY
从接口继承的字段 org.springframework.batch.core.Step
STEP_TYPE_KEY
构造器概要
构造器 构造器 说明 TaskletStep()
Default constructor.TaskletStep(java.lang.String name)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 JobOperatorprotected 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 singleItemStream
for callbacks to the stream interface.void
setChunkListeners(ChunkListener[] listeners)
Register each of the objects as listeners.void
setInterruptionPolicy(StepInterruptionPolicy interruptionPolicy)
Setter for theStepInterruptionPolicy
.void
setStepOperations(RepeatOperations stepOperations)
TheRepeatOperations
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 theTasklet
.void
setTransactionAttribute(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute)
Public setter for theTransactionAttribute
.void
setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Public setter for thePlatformTransactionManager
.从类继承的方法 org.springframework.batch.core.step.AbstractStep
doExecutionRegistration, doExecutionRelease, execute, getCompositeListener, getJobRepository, getName, getStartLimit, isAllowStartIfComplete, registerStepExecutionListener, setAllowStartIfComplete, setBeanName, setJobRepository, setName, setStartLimit, setStepExecutionListeners, toString
字段详细资料
TASKLET_TYPE_KEY
public static final java.lang.String TASKLET_TYPE_KEY
- 另请参阅:
- 常量字段值
构造器详细资料
TaskletStep
public TaskletStep()
Default constructor.
TaskletStep
public TaskletStep(java.lang.String name)
- 参数:
name
- the name for theTaskletStep
方法详细资料
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
- 指定者:
afterPropertiesSet
在接口中org.springframework.beans.factory.InitializingBean
- 覆盖:
afterPropertiesSet
在类中AbstractStep
- 抛出:
java.lang.Exception
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Public setter for thePlatformTransactionManager
.- 参数:
transactionManager
- the transaction manager to set
setTransactionAttribute
public void setTransactionAttribute(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute)
Public setter for theTransactionAttribute
.- 参数:
transactionAttribute
- theTransactionAttribute
to set
setTasklet
public void setTasklet(Tasklet tasklet)
Public setter for theTasklet
.- 参数:
tasklet
- theTasklet
to set
registerChunkListener
public void registerChunkListener(ChunkListener listener)
Register a chunk listener for callbacks at the appropriate stages in a step execution.- 参数:
listener
- aChunkListener
setChunkListeners
public void setChunkListeners(ChunkListener[] listeners)
Register each of the objects as listeners.- 参数:
listeners
- an array of listener objects of known types.
setStreams
public void setStreams(ItemStream[] streams)
Register each of the streams for callbacks at the appropriate time in the step. TheItemReader
andItemWriter
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 implementItemWriter
using delegation to another object which itself is aItemStream
, you need to register the delegate here.- 参数:
streams
- an array ofItemStream
objects.
registerStream
public void registerStream(ItemStream stream)
Register a singleItemStream
for callbacks to the stream interface.- 参数:
stream
- instance ofItemStream
setStepOperations
public void setStepOperations(RepeatOperations stepOperations)
TheRepeatOperations
to use for the outer loop of the batch processing. Should be set up by the caller through a factory. Defaults to a plainRepeatTemplate
.- 参数:
stepOperations
- aRepeatOperations
instance.
setInterruptionPolicy
public void setInterruptionPolicy(StepInterruptionPolicy interruptionPolicy)
Setter for theStepInterruptionPolicy
. The policy is used to check whether an external request has been made to interrupt the job execution.- 参数:
interruptionPolicy
- aStepInterruptionPolicy
doExecute
protected void doExecute(StepExecution stepExecution) throws java.lang.Exception
Process the step and update its context so that progress can be monitored by the caller. The step is broken down into chunks, each one executing in a transaction. The step and its execution and execution context are all given an up to dateBatchStatus
, and theJobRepository
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'sExecutionContext
.- 指定者:
doExecute
在类中AbstractStep
- 参数:
stepExecution
- the current step context- 抛出:
JobInterruptedException
- if the step or a chunk is interruptedjava.lang.RuntimeException
- if there is an exception during a chunk executionjava.lang.Exception
- checked exception thrown by implementation
createSemaphore
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.- 返回:
- a semaphore for locking access to the JobRepository
close
protected void close(ExecutionContext ctx) throws java.lang.Exception
从类复制的说明:AbstractStep
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. Does nothing by default.- 覆盖:
close
在类中AbstractStep
- 参数:
ctx
- theExecutionContext
to use- 抛出:
java.lang.Exception
- checked exception thrown by implementation
open
protected void open(ExecutionContext ctx) throws java.lang.Exception
从类复制的说明:AbstractStep
Extension point for subclasses to provide callbacks to their collaborators at the beginning of a step, to open or acquire resources. Does nothing by default.- 覆盖:
open
在类中AbstractStep
- 参数:
ctx
- theExecutionContext
to use- 抛出:
java.lang.Exception
- checked exception thrown by implementation
getTasklet
public Tasklet getTasklet()
retrieve the tasklet - helper method for JobOperator- 返回:
- the
Tasklet
instance being executed within this step